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 57538 - Wrong implementation of DatabaseConnection default constructor
Summary: Wrong implementation of DatabaseConnection default constructor
Status: CLOSED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 4.x
Hardware: All All
: P1 blocker (vote)
Assignee: Nam Nguyen
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-06 12:33 UTC by Vladimir Yaroslavskiy
Modified: 2006-03-24 12:55 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Patched DatabaseConnection.java (8.30 KB, patch)
2005-04-06 23:56 UTC, Nam Nguyen
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Yaroslavskiy 2005-04-06 12:33:19 UTC
DataDirect jdbc drivers (DB2, Oracle, Sybase, MS SQL Server) don't
work in Java Studio Enterprise 8 (Buzz) after changes made in
DatabaseConnection.

See bug CR 6250647 "can not establish connection to DataDirect drivers"
in Bugster and cvs log:

----------------------------
revision 1.34
date: 2005/03/25 15:07:52; author: nnguyen; state: Exp; lines: +42 -17
issue 56861 Use service lookup for OpenConnectionInterface
----------------------------

I've investigated source code and found that invoking of
'New Database Connection' dialog (select a driver and call
'Connect Using...' item) runs default constructor of
DatabaseConnection.

In previous version (1.32) it was

/** Default constructor */
public DatabaseConnection() {
  propertySupport = new PropertyChangeSupport(this);

// For Java Studio Enterprise. Create instanceof OpenConnection
  try {
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    openConnection =  (OpenConnectionInterface)
    Class.forName(bundle.getString("CLASS_open_connection"), true,
    cl).newInstance();
  } catch(Exception ex) {
    org.openide.ErrorManager.getDefault().notify(ex);
  }
}

where openConnection variable was set by my implementation
com.sun.tools.dbdrivers.JseOpenConnection which sets/resets
password for unlocking driver.

But now constructor is:

/** Default constructor */
public DatabaseConnection() {
  propertySupport = new PropertyChangeSupport(this);
  openConnection = new OpenConnection();
}

where openConnection is empty default implementation.

/** Default constructor */
public DatabaseConnection() {
  propertySupport = new PropertyChangeSupport(this);

  // For Java Studio Enterprise. Create instanceof OpenConnection
  try {
    Collection c = getOpenConnections();
    for (Iterator i=c.iterator(); i.hasNext();) {
      OpenConnectionInterface oci = (OpenConnectionInterface) i.next();
      openConnection = oci;
      break;
    }
  }
  catch(Exception ex) {
    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex);
  }
}

It seems not a good patch but might be fast way to solve the problem.
Comment 1 Nam Nguyen 2005-04-06 19:11:24 UTC
My overlook, not alerted enough when changing the defautl constructor.
I have a better fix.  Will post a patch, checkin trunk and wait for release41
approval.
Comment 2 Nam Nguyen 2005-04-06 23:56:38 UTC
Created attachment 21435 [details]
Patched DatabaseConnection.java
Comment 3 Nam Nguyen 2005-04-07 00:44:46 UTC
The patch is tested against Oracle in Buzz environement.  Also tested against
NetBeans PointBase driver and connection.

Checked in to trunk.

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.36; previous revision: 1.35

Needs reviews@netbeans.org for release41 integration.
Ludo is offering to take care of this.  Thanks.
Vladimir (Yaroslavskiy) please help test in Buzz against other drivers.  Thanks.
Comment 4 _ ludo 2005-04-07 00:58:45 UTC
41_HR_FIX  keyword added
Comment 5 Vladimir Yaroslavskiy 2005-04-07 12:06:46 UTC
Verified against DB2, Oracle
Comment 6 _ ludo 2005-04-08 04:06:49 UTC
This fix does not introduce regression in our sun resources zero config area, so
it is safe, so far.
Comment 7 Petr Jiricka 2005-04-11 18:03:21 UTC
Petre B, can you please verify that this does not break anything?
Comment 8 Petr Blaha 2005-04-11 20:18:37 UTC
OK, I will test it more thoroughly.
Comment 9 Jan Horvath 2005-04-12 14:40:35 UTC
verified in build 200504101930 against MS SQL
Comment 10 _ ludo 2005-04-12 19:32:02 UTC
integrated into 41 branch.
Ludo
Comment 11 zikmund 2005-07-12 16:16:14 UTC
v