Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

No Driver, still connecting

 
Andrew Shafer
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Perhaps some other process within the JVM is loading the Driver?
 
Andrew Shafer
Ranch Hand
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 338
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic