Re: JDBC and JVM question
From: Joe Weinstein (joeNOSPAM_at_bea.com)
Date: 11/01/03
- Next message: Dave Glasser: "Re: JDBC and JVM question"
- Previous message: Joe Weinstein: "Re: JDBC and JVM question"
- In reply to: Joe Weinstein: "Re: JDBC and JVM question"
- Next in thread: Dave Glasser: "Re: JDBC and JVM question"
- Reply: Dave Glasser: "Re: JDBC and JVM question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 01 Nov 2003 13:30:46 -0800
Joe Weinstein wrote:
> I just checked the very latest 5.5 EBF driver. It still only registers
> itself on instantiation:
>
> public class SybDriver
> implements com.sybase.jdbcx.SybDriver
> {
>
> public SybDriver()
> {
> _version = 5;
> registerWithDriverManager();
> }
>
> I also checked to see if this was redundant, and no, there is
> no static initializer block. Furthermore, the registerWithDriverManager
> routine goes through a silly fire drill of looking for any other driver
> instance so as to deregister it and register this new instance. Thus
> every time some one runs the newInstance() call, there is a needless
> change of regime in DriverManager from one perfectly good driver instance
> to an identical (the class is loaded only once) new one...
> "Chaqu'un sans gout"...
> Joe Weinstein at BEA
>
> PS:
> You could test it by a simple program that just does
> Class.forName() (without calling for a new instance), and then call the
> DriverManager call to list the loaded drivers.
I take it back partially! I couldn't simply doubt you so I ran the test
I suggested, and found that the 5.2 and 5.5 driver does have a static block,
that does instantiate a Driver instance. It doesn't explicitly register
the instance, which is why I missed finding it the first time. Instead,
it relies on the code I showed you above in the constructor, to do the
registering (which as I said, occurs every time newInstance() *or*
Class.forName() is called. It would be much more efficient of they just
had the static block be:
static
{
DriverManager.registerDriver(new SybDriver());
}
And the constructor be:
public SybDriver()
{
_version = 5;
}
There would be no need for the registerWithDriverManager() routine.
Joe Weinstein at BEA
- Next message: Dave Glasser: "Re: JDBC and JVM question"
- Previous message: Joe Weinstein: "Re: JDBC and JVM question"
- In reply to: Joe Weinstein: "Re: JDBC and JVM question"
- Next in thread: Dave Glasser: "Re: JDBC and JVM question"
- Reply: Dave Glasser: "Re: JDBC and JVM question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|