aspose file tools*
The moose likes JDBC and the fly likes Configuring jdbc connections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Configuring jdbc connections" Watch "Configuring jdbc connections" New topic
Author

Configuring jdbc connections

Tomasz Ducin
Greenhorn

Joined: Jan 22, 2013
Posts: 10

Hello everyone

I'd like to get a better understanding of how JDBC works.

As far as I understood, JDBC is (originally) Sun's interface for connecting dbs. Each implementation is a db driver, such as mysql or derby. JDBC URL is just a pattern, e.g. jdbc:driver://localhost:port/database_name, so it's parametrized.

If I want to connect to a database from any application without an IDE, say a small console application, I need to include a .jar with the driver and configure the connection inside the app (url, user, password, etc.). Is it all I should take care of? I mean - inside the NetBeans IDE there is 'services' tab next to 'projects' and 'files', where I add and remove jdbc connections. Are these just shortcuts to existing database so that I can access them (by clicking) faster or are they some kind of connection objects stored anywhere so that I shall create such objects in my console application?

Please correct me if I misunderstood anything. I'm a newbie, so forgive me silly questions... Thanks in advance!
Martin Vajsar
Sheriff

Joined: Aug 22, 2010
Posts: 3610
    
  60

Welcome to the Ranch, Tomasz!

Yes, your understanding is correct. You don't need to set up any connections in the IDE for your program to be able to access the database. All you need is a JDBC driver on the classpath, initialization of the driver in your startup code (prior to JDBC 4.0 driver autoload, that is), and a connection URL.
Tomasz Ducin
Greenhorn

Joined: Jan 22, 2013
Posts: 10

Many thanks for your reply. It's easier to get a valuable response here than on stack overflow
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Configuring jdbc connections