Bugs item #799730, was opened at 2003-09-03 11:16
Message generated for change (Settings changed) made by ejort
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=799730&group_id=22866

>Category: JBossCX
Group: v4.0
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Craig Munday (cmunday)
>Assigned to: Adrian Brock (ejort)
Summary: JDBC Driver being registered twice.

Initial Comment:
Windows 2000

JDK 1.4.2

JBOSS 4.0DR2



I am currently writing a JDBC Driver and have noticed 

that JBoss does not initialise the driver class the first 

time an attempt to load it is made - hence the static 

initialiser is not called.  My driver contains the 

recommended initialiser and should be compliant:



public class MyDriver implements java.sql.Driver

{

    static

    {

        java.sql.DriverManager.registerDriver(new MyDriver

());

    }

    . . . 

}



The method having the problem is:



protected void checkDriver(final String url) throws 

ResourceException



when it attempts to load the driver class with the 

following code:



//try to load the class... this should register with 

DriverManager.

         Class clazz = Thread.currentThread

().getContextClassLoader().loadClass(driverClass);



It appears that the ClassLoader.loadClass() method does 

not initialize the driver class which means the static 

initialiser will not be invoked.



The specification states that the driver class should be 

loaded with the Class.forName(...) method which WILL 

initialise the class (and invoke the Driver's static 

initialiser).



The code following the call to loadClass() will load the 

driver twice because the first attempt (described above) 

will not succeed.





----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=376685&aid=799730&group_id=22866


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
JBoss-Development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to