This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes JDBC and the fly likes No Driver, still connecting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Databases » JDBC
Bookmark "No Driver, still connecting" Watch "No Driver, still connecting" New topic
Author

No Driver, still connecting

Andrew Shafer
Ranch Hand

Joined: Jan 19, 2001
Posts: 338

I don't really have a problem, mostly a curiosity.
I had a JSP querying a PostgreSQL server on a different machine. Everything worked great.
Then I got a new server, so I started the migration.
The new server had a newer version of Postgres and the new drivers were in a different package name than the ones needed for the DB that it needs to connect to.
Without really thinking about it, I tried to run the JSP. It compiled, runs, comes back and tell me it failed to load the driver (because it isn't in the same place) and then connects to the DB and returns the results.
I thought that was odd, so for experiment, I deleted the

and everything works just fine.
Does anybody know why the database seems to accept connections without loading the driver?
I just thought it was puzzling.


!_I_Know_Kung_Fu_!
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
Perhaps some other process within the JVM is loading the Driver?


Associate Instructor - Hofstra University
Amazon Top 750 reviewer - Blog - Unresolved References - Book Review Blog
Andrew Shafer
Ranch Hand

Joined: Jan 19, 2001
Posts: 338

I must admit, I'm no java expert, especially when it comes to details about the JVM.
Everything is a JSP or a servlet running in Tomcat. There is another application that loads a driver for a much newer version of PostgreSQL but that driver doesn't even have the same name or belong in the same package.
Does everything in the JVM share the same driver? If that is the case, what if you had an application that needed to connect to two seperate DB with two seperate drivers. Wouldn't that create conflict?
Do you know any thing to read about this? Most articles about JDBC are about how to use the API, not specifics about JVM and such.
Thomas Paul
mister krabs
Ranch Hand

Joined: May 05, 2000
Posts: 13974
If one application loads a driver then anyone who needs that same driver would use it. But the way it determines which driver to use is dependent on the URL you specify not the name of the driver. So let's say that you need a driver that uses a url starting with jdbc:sybase and someone loads a driver that uses that same prefix. If you load a driver that also uses a URL with that prefix then you would actually use the first one that was loaded.
Andrew Shafer
Ranch Hand

Joined: Jan 19, 2001
Posts: 338

Thomas, you are awsome
If I don't use the other app first, then it won't connect.
So once a driver has been instatiated, any app in the same JVM will use it, if the database has the same designation in the URL.
At some point it seems like it would be possible to have two database with the same designation, with incompatible drivers.
Seems like loading and unloading the drivers could get problematic.
Anyone forsee this as a problem or have any experience with this?
 
GeeCON Prague 2014
 
subject: No Driver, still connecting