Re: JDBC and JVM question
From: Dave Glasser (dglasser_at_pobox.com)
Date: 11/01/03
- Next message: Anthony Borla: "Re: How to check Database exist"
- Previous message: Joe Weinstein: "Re: JDBC and JVM question"
- In reply to: Joe Weinstein: "Re: JDBC and JVM question"
- Next in thread: Joe Weinstein: "Re: JDBC and JVM question"
- Reply: Joe Weinstein: "Re: JDBC and JVM question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 01 Nov 2003 17:00:52 -0500
Joe Weinstein <joeNOSPAM@bea.com> wrote on Sat, 01 Nov 2003 13:30:46
-0800 in comp.lang.java.databases:
>
>
>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.
I'm not sure, because I haven't used Sybase since mid-2001, but I
think the classname we were passing to Class.forName was
com.sybase.jdbc2.jdbc.SybDriver, not com.sybase.jdbcx.SybDriver. Could
that account for the difference? I do remember clearly that
Class.forName worked, though, because some of my very first JDBC (and
Java) code was written against a Sybase database, and that's all I
knew how to do at the time.
- Next message: Anthony Borla: "Re: How to check Database exist"
- Previous message: Joe Weinstein: "Re: JDBC and JVM question"
- In reply to: Joe Weinstein: "Re: JDBC and JVM question"
- Next in thread: Joe Weinstein: "Re: JDBC and JVM question"
- Reply: Joe Weinstein: "Re: JDBC and JVM question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|