This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 69883 - Connection is using random driver implementation
Summary: Connection is using random driver implementation
Status: VERIFIED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 5.x
Hardware: All All
: P2 blocker (vote)
Assignee: Andrei Badea
URL:
Keywords: API, API_REVIEW, REGRESSION
Depends on:
Blocks:
 
Reported: 2005-12-05 13:32 UTC by Martin Schovanek
Modified: 2005-12-16 13:15 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Proposed change (51.15 KB, text/plain)
2005-12-07 20:12 UTC, Andrei Badea
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Schovanek 2005-12-05 13:32:46 UTC
[#200512041900, jdk1.5.0]

to reproduce:
-------------
1) register two drivers with the same Driver Class, e.g.: Oracle9.2 and
Oracle9.0 drivers.
2) create two drivers connection, first using Oracle9.2 driver an second using
Oracle9.0
3) disconnect both connections
4) remove the Oracle9.0 driver registration
5) connect the second connection
ERROR: connection was established although the Oracle9.0 driver is unregistered
6) disconnect it and remove the Oracle9.2 driver registration
7) connect the second connection again
NOTE: IDE throws: 'The OracleDriver class was not found' error message, it
confirms that the connection used wrong driver instance in step 5).
Comment 1 Andrei Badea 2005-12-07 20:11:17 UTC
Caused by the connection registration format lacking something like a "driver
id". Only the driver class is there, so if two different drivers with the same
class name are registered in the IDE, the incorrect one may be used to connect.

In NB 4.1 the connection contained the driver name (the name property of the
JDBCDriver class) along with the driver class. But on the other hand the driver
name was (and still is) used for displaying the driver in the UI. So the same
property was used to programmatically identify the driver and display it in the
UI. What's missing here is a displayName property.

I propose an API change which incompatibly changes the name property of
JDBCDriver to be a programmatic name and adds a displayName property which will
be used to display the driver in the UI. An element containing the driver name
is added to the connection registration format, fixing this issue.

All the changes necessary in the db module are in the attached diff. The changes
are:

- added a displayName property to JDBCDriver and modified the create() factory
method appropriately
- added a new version (1.1) of the JDBC driver DTD containing a display-name
element. Needed since the version 1.0 can't be changed incompatibly, as it has
been used in previous releases.
- added a driver-name element to the database connection DTD
- made the necessary changes to the Environment.Provider implementations for the
driver and connection DTDs in order to read the new elements
(JDBCDriverConvertor and DatabaseConnectionConvertor)
- made the necessary changes for the displayName property of JDBCDriver to be
used in the UI
- modified the tests to ensure the new elements are read and written correctly 

I would like to ask for a review. The reviewers for this issue are pbuzek,
rkubacki, rnajman and jtulach.
Comment 2 Andrei Badea 2005-12-07 20:12:12 UTC
Created attachment 27650 [details]
Proposed change
Comment 3 Pavel Buzek 2005-12-07 22:36:18 UTC
I agree with the fix. I do not see any problem with the change, seems like the
right thing to do.
Comment 4 _ rkubacki 2005-12-07 22:56:08 UTC
I do not see any problem too
Comment 5 Jaroslav Tulach 2005-12-08 08:36:52 UTC
Generally ok. 
 
minor="16" - you have interesting way of counting, usually people just 
increment minor version. However =+X is also ok if X>=1 
 
by marking the change incompatible (which it is, but before first release) you 
may scare your users. Check generated apichanges.html and you will see. So I 
advice to keep the incompatible change in secret. 
 
Maybe you want to add @since 1.16 to the factory method you have added. 
Comment 6 Andrei Badea 2005-12-08 13:05:00 UTC
To jtulach:

Re. "interesting" counting: what do you mean exactly? I incremented the current
version (1.15) by 1. Are you refering to the change from 1.0 to 1.13 in the
first <change> tag in the apichanges.xml file? If so, that's a just an unrelated
fix -- the DB Exp API was introduced in the version 1.13 of the module, not 1.0.

Re. keeping the incompatible change in secret: so should I not mention the
change in apichanges.xml at all?

Re. @since tag: if I add it, I will have to document the change in
apichanges.xml, won't I? Otherwise it won't be clear for clients how the change
was introduced in version 1.16 when the only change in apichanges.xml is in
version 1.13.

Thanks to all for the review. Still waiting for Radko.
Comment 7 Radko Najman 2005-12-08 14:54:32 UTC
I'm sorry for late answer, I was away. It seems ok to me.
Comment 8 Andrei Badea 2005-12-08 15:51:37 UTC
Integrated.

Checking in arch.xml;
/cvs/db/arch.xml,v  <--  arch.xml
new revision: 1.9; previous revision: 1.8
done
Checking in src/org/netbeans/api/db/explorer/JDBCDriver.java;
/cvs/db/src/org/netbeans/api/db/explorer/JDBCDriver.java,v  <--  JDBCDriver.java
new revision: 1.3; previous revision: 1.2
done
Checking in src/org/netbeans/modules/db/explorer/DatabaseConnection.java;
/cvs/db/src/org/netbeans/modules/db/explorer/DatabaseConnection.java,v  <-- 
DatabaseConnection.java
new revision: 1.46; previous revision: 1.45
done
Checking in src/org/netbeans/modules/db/explorer/DatabaseConnectionConvertor.java;
/cvs/db/src/org/netbeans/modules/db/explorer/DatabaseConnectionConvertor.java,v
 <--  DatabaseConnectionConvertor.java
new revision: 1.6; previous revision: 1.5
done
Checking in src/org/netbeans/modules/db/explorer/DatabaseDriver.java;
/cvs/db/src/org/netbeans/modules/db/explorer/DatabaseDriver.java,v  <-- 
DatabaseDriver.java
new revision: 1.14; previous revision: 1.13
done
Checking in src/org/netbeans/modules/db/explorer/DatabaseOption.java;
/cvs/db/src/org/netbeans/modules/db/explorer/DatabaseOption.java,v  <-- 
DatabaseOption.java
new revision: 1.30; previous revision: 1.29
done
Checking in src/org/netbeans/modules/db/explorer/DbURLClassLoader.java;
/cvs/db/src/org/netbeans/modules/db/explorer/DbURLClassLoader.java,v  <-- 
DbURLClassLoader.java
new revision: 1.3; previous revision: 1.2
done
Checking in src/org/netbeans/modules/db/explorer/actions/AddDriverAction.java;
/cvs/db/src/org/netbeans/modules/db/explorer/actions/AddDriverAction.java,v  <--
 AddDriverAction.java
new revision: 1.24; previous revision: 1.23
done
Checking in
src/org/netbeans/modules/db/explorer/actions/ConnectUsingDriverAction.java;
/cvs/db/src/org/netbeans/modules/db/explorer/actions/ConnectUsingDriverAction.java,v
 <--  ConnectUsingDriverAction.javanew revision: 1.32; previous revision: 1.31
done
Checking in src/org/netbeans/modules/db/explorer/actions/CustomizeDriverAction.java;
/cvs/db/src/org/netbeans/modules/db/explorer/actions/CustomizeDriverAction.java,v
 <--  CustomizeDriverAction.java
new revision: 1.6; previous revision: 1.5
done
Checking in src/org/netbeans/modules/db/explorer/dlg/AddDriverDialog.java;
/cvs/db/src/org/netbeans/modules/db/explorer/dlg/AddDriverDialog.java,v  <-- 
AddDriverDialog.java
new revision: 1.34; previous revision: 1.33
done
Checking in src/org/netbeans/modules/db/explorer/dlg/NewConnectionPanel.java;
/cvs/db/src/org/netbeans/modules/db/explorer/dlg/NewConnectionPanel.java,v  <--
 NewConnectionPanel.java
new revision: 1.18; previous revision: 1.17
done
Checking in src/org/netbeans/modules/db/explorer/driver/JDBCDriverConvertor.java;
/cvs/db/src/org/netbeans/modules/db/explorer/driver/JDBCDriverConvertor.java,v 
<--  JDBCDriverConvertor.java
new revision: 1.12; previous revision: 1.11
done
Checking in src/org/netbeans/modules/db/explorer/infos/DriverListNodeInfo.java;
/cvs/db/src/org/netbeans/modules/db/explorer/infos/DriverListNodeInfo.java,v 
<--  DriverListNodeInfo.java
new revision: 1.24; previous revision: 1.23
done
Checking in src/org/netbeans/modules/db/explorer/infos/DriverNodeInfo.java;
/cvs/db/src/org/netbeans/modules/db/explorer/infos/DriverNodeInfo.java,v  <-- 
DriverNodeInfo.java
new revision: 1.24; previous revision: 1.23
done
Checking in src/org/netbeans/modules/db/resources/JDBCODBC.xml;
/cvs/db/src/org/netbeans/modules/db/resources/JDBCODBC.xml,v  <--  JDBCODBC.xml
new revision: 1.3; previous revision: 1.2
done
Checking in src/org/netbeans/modules/db/resources/connection-1_0.dtd;
/cvs/db/src/org/netbeans/modules/db/resources/connection-1_0.dtd,v  <-- 
connection-1_0.dtd
new revision: 1.5; previous revision: 1.4
done
Checking in src/org/netbeans/modules/db/resources/jdbc-driver-1_0.dtd;
/cvs/db/src/org/netbeans/modules/db/resources/jdbc-driver-1_0.dtd,v  <-- 
jdbc-driver-1_0.dtd
new revision: 1.3; previous revision: 1.2
done
RCS file: /cvs/db/src/org/netbeans/modules/db/resources/jdbc-driver-1_1.dtd,v
done
Checking in src/org/netbeans/modules/db/resources/jdbc-driver-1_1.dtd;
/cvs/db/src/org/netbeans/modules/db/resources/jdbc-driver-1_1.dtd,v  <-- 
jdbc-driver-1_1.dtd
initial revision: 1.1
done
Checking in src/org/netbeans/modules/db/resources/mf-layer.xml;
/cvs/db/src/org/netbeans/modules/db/resources/mf-layer.xml,v  <--  mf-layer.xml
new revision: 1.12; previous revision: 1.11
done
Checking in src/org/netbeans/modules/db/util/DriverListUtil.java;
/cvs/db/src/org/netbeans/modules/db/util/DriverListUtil.java,v  <-- 
DriverListUtil.java
new revision: 1.12; previous revision: 1.11
done
Checking in
test/unit/src/org/netbeans/modules/db/explorer/DatabaseConnectionConvertorTest.java;
/cvs/db/test/unit/src/org/netbeans/modules/db/explorer/DatabaseConnectionConvertorTest.java,v
 <--  DatabaseConnectionConvertorTest.java
new revision: 1.5; previous revision: 1.4
done
Checking in test/unit/src/org/netbeans/modules/db/explorer/DbDriverManagerTest.java;
/cvs/db/test/unit/src/org/netbeans/modules/db/explorer/DbDriverManagerTest.java,v
 <--  DbDriverManagerTest.java
new revision: 1.4; previous revision: 1.3
done
Checking in test/unit/src/org/netbeans/modules/db/explorer/bar-connection.xml;
/cvs/db/test/unit/src/org/netbeans/modules/db/explorer/bar-connection.xml,v  <--
 bar-connection.xml
new revision: 1.4; previous revision: 1.3
done
Checking in
test/unit/src/org/netbeans/modules/db/explorer/driver/JDBCDriverConvertorTest.java;
/cvs/db/test/unit/src/org/netbeans/modules/db/explorer/driver/JDBCDriverConvertorTest.java,v
 <--  JDBCDriverConvertorTest.java
new revision: 1.6; previous revision: 1.5
done
Checking in test/unit/src/org/netbeans/modules/db/explorer/driver/bar-driver.xml;
/cvs/db/test/unit/src/org/netbeans/modules/db/explorer/driver/bar-driver.xml,v 
<--  bar-driver.xml
new revision: 1.3; previous revision: 1.2
done
Checking in nbproject/project.properties;
/cvs/db/nbproject/project.properties,v  <--  project.properties
new revision: 1.13; previous revision: 1.12
done
Comment 9 Andrei Badea 2005-12-08 16:23:05 UTC
Uploaded the JDBC driver and connection DTDs to http://www.netbeans.org/dtds.

cvs commit: Examining .
Checking in jdbc-driver-1_0.dtd;
/cvs/www/www/dtds/jdbc-driver-1_0.dtd,v  <--  jdbc-driver-1_0.dtd
new revision: 1.3; previous revision: 1.2
done
RCS file: /cvs/www/www/dtds/jdbc-driver-1_1.dtd,v
done
Checking in jdbc-driver-1_1.dtd;
/cvs/www/www/dtds/jdbc-driver-1_1.dtd,v  <--  jdbc-driver-1_1.dtd
initial revision: 1.1
done
Checking in connection-1_0.dtd;
/cvs/www/www/dtds/connection-1_0.dtd,v  <--  connection-1_0.dtd
new revision: 1.2; previous revision: 1.1
done
Comment 10 Jesse Glick 2005-12-08 19:16:13 UTC
Commit caused at least two build breakages - in db/derby and in
serverplugins/sun/appsrv81.
Comment 11 Jesse Glick 2005-12-08 19:40:06 UTC
And a commit validation failure in ValidateLayerConsistencyTest:

Cannot instantiate org.netbeans.modules.db.explorer.driver.JDBCDriverConvertor
for MultiFileObject@c0bc3a[xml/lookups/NetBeans/DTD_JDBC_Driver_1_0.instance]

Caused by: java.lang.IllegalAccessException: Class
org.openide.loaders.InstanceSupport can not access a member of class
org.netbeans.modules.db.explorer.driver.JDBCDriverConvertor with modifiers "private"

I am trying to figure out what it means, but I am not sure. instanceCreate
methodvalue="..." is not working for some reason.
Comment 12 Andrei Badea 2005-12-08 20:59:56 UTC
The CV failure was caused by the bad providerRef WeakReference handling in the
createProvider() method. There is a moment between creating the
JDBCDriverConvertor instance and returning it when it is only hold by the weak
reference.

I've just fixed it. Thanks for trying to help!
Comment 13 Martin Schovanek 2005-12-16 13:15:19 UTC
VERIFIED