• 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

generalised code to connect to database engines using jdbc4?

 
Greenhorn
Posts: 2
Firefox Browser Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

i am developing an application which simulates datacubes and their operation. For this application i need to provide support for various database engines such as postgresql, mysql, etc.
i was planning on providing an interface where the user can choose the engine and specify its details.

i have been able to connect to postgresql using the jdbc4 driver available. for this connection i had to compile my program code by including the .jar driver in the classpath during compilation.
but the application as a product should run on JRE and there should be no need to recompile the code. is this possible?

the application should also be customizable to the newer versions of driver and engines available for the database. How can this be done? please guide me in the right direction

HOW CAN THIS CONDITIONALITY BE ACHIEVED?
please help.

thanks in advance
 
Sheriff
Posts: 22783
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See http://docs.oracle.com/javase/tutorial/jdbc/basics/index.html, especially http://docs.oracle.com/javase/tutorial/jdbc/basics/connecting.html. In essence, you use Class.forName to load the driver class instead of hard coding it, and then use DriverManager to get the connection. There will only be two values you then may need to change - the class name and the connection string.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic