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 35738 - DB explorer does not disconnect reliably
Summary: DB explorer does not disconnect reliably
Status: VERIFIED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Code (show other bugs)
Version: 3.x
Hardware: PC Windows 95/98
: P2 blocker (vote)
Assignee: Radko Najman
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-08-24 10:14 UTC by bht
Modified: 2004-08-23 16:20 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
This class fails to connect to the database after it is closed in Netbeans (677 bytes, patch)
2003-10-15 22:11 UTC, bht
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description bht 2003-08-24 10:14:06 UTC
Sometimes, when a connection is closed from within
the explorer, it looks like it is closed, but the
engine still has a connection. This can cause data
corruption with embedded databases. To test this,
one needs a reliable way to check that a
connection is still open. With an embedded
database, for instance, it is usually sufficient
to attempt to delete the database files, which
should always be possible after the DB explorer
closes its connection.
I can't make a testcase because it is not 100%
reproducible.
Comment 1 bht 2003-10-11 03:09:36 UTC
It appears to be almost 100% reproducible now. I have already lost
data a couple of times because with this there is no way of
disconnecting from the database at all. For an embedded database that
is a high risk operation, comparable with pulling the plug of a
machine that runs a database server.

There is definitely a leak in netbeans somewhere.

Why is this "future"?

It can't be good for netbeans to leave this as it is.
Comment 2 Radko Najman 2003-10-15 15:51:44 UTC
Cannot reproduce with dev build. There was a similar issue #25770 but
it was fixed a long time ago.

I added debug message to
org.netbeans.modules.db.explorer.infos.ConnectionNodeInfo.disconnect()
method. When the connection was closed by java.sql.Connection.close()
method I tested it with java.sql.Connection.isClosed() method and I
got always true. It meant that the connection was closed from the JDBC
API point of view. If you are sure that the connection is still open
it is probably a driver issue.

For QA: Martine, could you try to reproduce it, please?
Comment 3 bht 2003-10-15 20:27:47 UTC
Radko,

Thanks for investigating this.

You are probably quite correct in that the conection that you are
focusing on is closed properly.

But how do you know that not accidentally other connections are opened
and not closed?

My way of reproducing this is as follows, and I would suggest to use
this or a similar method to reproduce the error:

- Connect to QED with Netbeans
- Expand the tables node in the DB explorer to view the list of tables
- Disconnect with the DB explorer
- After this don't change anything in netbeanse, i.e. leave it running
- Try to open a connection the the same QED database from another Java
program.

This fails in most cases and only closing netbeans gets around that
problem.

Then, additionally, perform this test in the other direction:
- Close Netbeans
- Connect to QED with the other Java program.
- Disconnect from QED from the other Java program.
- Connect to QED with netBeans.

This has never failed so far.


Comment 4 bht 2003-10-15 22:09:09 UTC
Let me try to provide more information. It appears that success in
deleting the qed database directory is no longer a criterion for
failure. One needs another application to open a connection.

I reproduced the error once again on Windows 98 this morning:
In netbeans:
- I connect with a user name, but without password
- I check "Remember password during this session"
- I connect as generic database system
  (I realise the buttons on the dialog don't respond to mouse clicks -
So I use keyboard shortcuts)
- I right click on the connection icon and select "Disconnect"
- I delete the database directory in Windows Explorer (this did not
work when I first reported the bug but it works now)
- I restore the database directory from the recycle bin by pressing 
ctrl-z in Windows explorer
- I start an application in netbeans that opens a connection to this 
database.

The error is:
2003-10-16 09:53:47.030: [main] java.io.IOException: lockfile already
exists.  Maybe another process is accessing the database?
        at com.quadcap.sql.file.Datafile.init(Datafile.java:390)
        at com.quadcap.sql.Database.init(Database.java:121)
        at com.quadcap.jdbc.JdbcDriver.connect(JdbcDriver.java:225)

So the deleting of the database directory is no longer helpful to
verify this bug. One needs another java application that connects to
the same database.
Comment 5 bht 2003-10-15 22:11:35 UTC
Created attachment 11877 [details]
This class fails to connect to the database after it is closed in Netbeans
Comment 6 Radko Najman 2003-10-16 17:25:41 UTC
I tried to reproduce the problem by both ways which you described. It
worked for me without any problem, no exception was thrown, the
connection was always established.

Could you try it with my yesterday's changes, please? Download dev
build from Oct 16 (#200310160100) or later from
http://www.netbeans.org/downloads/ide/development.html and I hope it
will work for you.
Comment 7 bht 2003-10-16 22:31:04 UTC
Great. It works flawlessly in the latest development build. Radko, you
probably know best what fixed it. I just mark this as worksforme.

Thanks again for your help.
Comment 8 dmladek 2004-08-23 16:19:12 UTC
I would mark it FIXED... 
Comment 9 dmladek 2004-08-23 16:19:55 UTC
marking as FIXED
Comment 10 dmladek 2004-08-23 16:20:45 UTC
as Bernard comfirmed this bug is fixed, just verifying