This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 3606
    
  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
 
 
subject: Configuring jdbc connections
 
Similar Threads
Tutorial PostgreSQL 8.3 on Glassfish V2.1 for ConnectionPool in Netbeans 6.5.1, WindowsXP (Post 3)
Trouble with JDBC Connection Pooling
Issue Connecting to MS SQL Server using WAS Embedded connectjdbc Driver
Need help learning about databases
UNmanaged JBoss Connection Pool wanted!