lesteryu / log4jdbc

Automatically exported from code.google.com/p/log4jdbc
0 stars 0 forks source link

Auto-Loading of JDBC Driver doesn't work #17

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Don't register the driver with Class.forName("net.sf.log4jdbc.DriverSpy");
2. Get a connection with jdbc:log4jdbc:...

What is the expected output? What do you see instead?
Expected: DriverManager should detect the driver itself.
Actual: No suitable driver found for jdbc:log4jdbc:...

What version of the product are you using? On what operating system?
WindowsXP, log4jdbc4-1.2beta1.jar

Please add a META-INF\services\java.sql.Driver file with the content
"net.sf.log4jdbc.DriverSpy" in the log4jdbc4-*.jar. This will automatically
register the driver (at least with flat classloaders, others I haven't tested).

Original issue reported on code.google.com by felix.wi...@bluewin.ch on 7 May 2010 at 10:29

GoogleCodeExporter commented 9 years ago
See: http://java.sun.com/javase/6/docs/api/java/sql/DriverManager.html

This functionality is only for JDBC 4 drivers.  One problem with automatically 
loading the log4jdbc driver, is that this particular driver then tries to load 
a 
number of other drivers.  If those drivers are also JDBC 4 drivers then 
presumably 
they would have been loaded anyway if they followed the spec, so it wouldn't be 
an 
issue-- However since log4jdbc could potentionally load a number of JDBC 3 
drivers 
that wouldn't otherwise be loaded automatically, I'm not so sure this is a good 
idea.  

This could have a snowball effect in loading a lot of drivers that you didn't 
intend.  
So for that reason, I think it might be better to continue making the loading 
of 
log4jdbc explicit.  

I've also been considering changing the automatic loading of other drivers as 
it has 
caused unintended consequences in the past.  If I do make a major change like 
that, 
then it might make more sense to follow the JDBC 4 spec correctly for the JDBC 
4 
version of log4jdbc.

Original comment by arthur.b...@gmail.com on 7 May 2010 at 11:29