• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How can i connect to remote database server using swings

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am using a swing application.I am not using the Japplets.In this application i want connect to the remote database and store and retrieve the data in and from remote database.I want to access my remote database through the internet.

for that which thechnology i will use? wheather igo for

1. normal jdbc connections?
2. Using Rmi
3. using servlets if possible
4. r there any other technology

please suggest me which one is better and feasible. please give code to do that or any resources or links for the information.

Thanks in advance
 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
1.) Normal JDBC should work OK (Just specify the correct URL for the connection, make sure you have the driver, make sure the network is open to the server, etc.) but will probably be a much more "fragile" solution than other options - since you are accessing the DB directly, any DB changes require a client change - whereas with other methods, you would be able to seperate client and server better.

2.) RMI could work too - you could hide the JDBC (or other data access) behind an RMI facade that would simply provide remote or serialized object versions of the data. Better than direct JDBC (because you are dealing with objects rather than directly with the database), and would certainly be sufficient, but there may be additional needs you have that might already be provided by another choice.

3.) Servlets are probably not the best choice - primarily because the dangers of SQL injection - using servlets and SQL, the first thing anyone thinks of is "Let's just make a servlet that takes a SQL string and calls the database". Very simple, but also very dangerous - because anyone can send any kind of SQL statement into this - deleting data, getting access to records they shouldn't, etc. Yes, it is possible to filter the input, but you have to be very careful, and it's easy to miss possible "bad" statements that can be sent - so it's better to just not use this.

4.) Other possible choices -
a.) Web Service - kind of like the servlet option, but more "object-like" - make sure you aren't sending SQL directly again - deal with objects - not SQL.
b.) EJB - may be more than you need - and probably a steep learning curve - but it should provide everything you should ever need for this plus more - transactions, objects instead of SQL, remote access, etc.
c.) Hibernate - or some other ORM (Object Relational Mapping) solution - point it at a database, tell it what tables to model as what kind of objects, and it handles the rest.

None of these are "the best" answer - it all depends on your exact project, the way your project accesses data, and your level of understanding of how to use any of these.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic