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.
... just after connecting with ConnectionManager.showConnectionDialog(). Subsequent calls seem to return the java.sql.Connection object as expected.
Isn't this because showConnectionDialog() can potentially run asynchronously on a different thread? Maybe we need a showConnectionDialogFromEventThread() method? public void showConnectionDialog() { try { final ConnectionNodeInfo cni = findConnectionNodeInfo(getName()); if (cni != null && cni.getConnection() == null) { Mutex.EVENT.readAccess(new Runnable() { public void run() { new ConnectAction.ConnectionDialogDisplayer().showDialog(cni, false); } }); } } catch (DatabaseException e) { Exceptions.printStackTrace(e); } }
It is possible. In my case the behavior was caused by a bug in my code (outside the DB Explorer). So I can't really reproduce the issue, so closing.
The issue still exists in the latest netbeans. Product Version: NetBeans IDE 6.1 (Build 200805300101) Invoking the same code second time around creates a connection successfully. Here's the code that I use. final Object item = this.datasourceComboBox.getSelectedItem(); if (item instanceof ConnectionWrapper) { final ConnectionWrapper cw = (ConnectionWrapper) item; this.selectedConnection = cw.getDatabaseConnection(); ConnectionManager.getDefault().showConnectionDialog(this.selectedConnection); Connection jDBCConnection = this.selectedConnection.getJDBCConnection(); }
In which thread are you calling getJDBCConnection()?
I have a JPanel which displays a comboBox with the list of connectionWrappers. When the user selects one of the items, the actionPerformed(Event) calls the following method. final Object item = this.datasourceComboBox.getSelectedItem(); if (item instanceof ConnectionWrapper) { final ConnectionWrapper cw = (ConnectionWrapper) item; this.selectedConnection = cw.getDatabaseConnection(); ConnectionManager.getDefault().showConnectionDialog(this.selectedConnection); Connection jDBCConnection = this.selectedConnection.getJDBCConnection(); } Currently, the user has to select the comboBox item twice to get connected.
So it is the event dispatching thread, that is good. So there may be a race condition somewhere. But before I go hunting it, could you please try to reproduce the issue against the newest build of 6.5? I recall fixing a race condition in the code called by getJDBCConnection() some time ago. Thanks.
Have not heard from pponnala since August, assuming this is fixed.
v