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 143798 - [65cat] Test for a connection before using it in SQL Editor
Summary: [65cat] Test for a connection before using it in SQL Editor
Status: VERIFIED FIXED
Alias: None
Product: db
Classification: Unclassified
Component: Show Data (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: _ ahimanikya
URL: http://statistics.netbeans.org/except...
Keywords:
Depends on: 143837
Blocks:
  Show dependency tree
 
Reported: 2008-08-13 18:50 UTC by azizi
Modified: 2008-08-28 17:53 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 90587


Attachments
stacktrace (2.72 KB, text/plain)
2008-08-13 18:50 UTC, azizi
Details
stacktrace (2.72 KB, text/plain)
2008-08-13 18:56 UTC, azizi
Details

Note You need to log in before you can comment on or make changes to this bug.
Description azizi 2008-08-13 18:50:21 UTC
Build: NetBeans IDE Dev (Build 200808061401)
VM: Java HotSpot(TM) Client VM, 10.0-b22, Java(TM) SE Runtime Environment, 1.6.0_06-b02
OS: Linux, 2.6.24-19-generic, i386

User Comments: 


Stacktrace: 
java.sql.SQLException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
        at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:0)
        at org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:0)
        at org.apache.derby.client.am.Statement.execute(Statement.java:0)
        at org.netbeans.modules.db.dataview.output.SQLExecutionHelper.executeSQLStatement(SQLExecutionHelper.java:554)
        at org.netbeans.modules.db.dataview.output.SQLExecutionHelper.access$000(SQLExecutionHelper.java:72)
        at org.netbeans.modules.db.dataview.output.SQLExecutionHelper$5.execute(SQLExecutionHelper.java:402)
Comment 1 azizi 2008-08-13 18:50:26 UTC
Created attachment 67295 [details]
stacktrace
Comment 2 azizi 2008-08-13 18:53:17 UTC
1.start IDE.
2.start Java DB server from services tab.
3.right click on one of jdbc:derby connections and select connect from menu.
4.right click on one table and select view data.
5.stop java DB server
6.from sql command result tab click on refresh button 
7. exception occur

I'm able to reproduce it again and again.
* It seems it relate to Issue 143796 but in another way and with different exception. 
Comment 3 azizi 2008-08-13 18:56:31 UTC
Build: NetBeans IDE Dev (Build 200808061401)
VM: Java HotSpot(TM) Client VM, 10.0-b22, Java(TM) SE Runtime Environment, 1.6.0_06-b02
OS: Linux, 2.6.24-19-generic, i386

User Comments: 


Stacktrace: 
java.sql.SQLException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
        at org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:0)
        at org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:0)
        at org.apache.derby.client.am.Statement.execute(Statement.java:0)
        at org.netbeans.modules.db.dataview.output.SQLExecutionHelper.executeSQLStatement(SQLExecutionHelper.java:554)
        at org.netbeans.modules.db.dataview.output.SQLExecutionHelper.access$000(SQLExecutionHelper.java:72)
        at org.netbeans.modules.db.dataview.output.SQLExecutionHelper$5.execute(SQLExecutionHelper.java:402)
Comment 4 azizi 2008-08-13 18:56:35 UTC
Created attachment 67296 [details]
stacktrace
Comment 5 azizi 2008-08-13 19:00:19 UTC
I found that it can be reproduce by clicking on other buttons from sql command result tab
Comment 6 David Vancouvering 2008-08-13 19:14:13 UTC
Well, yes, of course it occurs because you just shut down the server, and the JDBC connection is trying to talk to a
server that is no longer there.  What do you expect to happen in this situation?
Comment 7 azizi 2008-08-13 19:21:40 UTC
Thanks for checking it out,

I think showing exception menu in final product is not very good idea.
so just printing out a text message to show the user that server is shut down is better, I think.
Comment 8 David Vancouvering 2008-08-13 19:46:30 UTC
Oh, I see, it's the presentation.  I have to think about that, because each JDBC driver has a different way of saying
the database is disconnected.  I think the enhancement here is to do a better job of displaying errors when there is an
exception for the driver.  

Changing the title of the bug and changing it to an enhancement request.
Comment 9 Andrei Badea 2008-08-13 20:40:35 UTC
Sorry, but I disagree. Turning the unexpected exception dialog into a friendlier error message for a deterministic
exception can't be the subject of an enhancement request. It is a defect and we should make sure the exception is not
thrown to begin with. Perhaps we really need that test() method in issue 122944.
Comment 10 Andrei Badea 2008-08-13 20:41:24 UTC
By the way, this will be a dataview issue once a means to test the connection is in place.
Comment 11 David Vancouvering 2008-08-13 22:22:16 UTC
If I can translate what you're suggesting, it's that we should be able to detect if a connection is still valid?  Or are
you also saying the way we report exceptions in general needs to be adjusted.  If it's the latter, isn't that an
enhancement?

Anyway, we should at least be checking for Connection.isClosed() before submitting a query, but I'm not sure all JDBC
driver vendors will check the network connection when you call isClosed().
Comment 12 David Vancouvering 2008-08-14 00:24:20 UTC
OK, I'm going to go ahead and try to fix this.  I need to implement Issue 122944 (add a test() method) and then ahi if
you can test your connection before you use it.  We will probably need to add tests elsewhere inside our code, but this
is one of the main places it's needed.
Comment 13 David Vancouvering 2008-08-14 00:32:43 UTC
Changed dependent bug to the one focused on the test() method
Comment 14 David Vancouvering 2008-08-15 20:04:20 UTC
Hi, Ahi.  Once 143837 passes API review you can use the test() method to address this in the dataview module...
Comment 15 _ ahimanikya 2008-08-28 08:33:18 UTC
http://hg.netbeans.org/main/rev/d6de54097bda
Comment 16 Roman Mostyka 2008-08-28 14:02:47 UTC
Verified with build 080828.
Comment 17 Quality Engineering 2008-08-28 17:53:07 UTC
Integrated into 'main-golden', available in build *200808281401* on http://bits.netbeans.org/dev/nightly/
Changeset: http://hg.netbeans.org/main/rev/d6de54097bda
User: ahimanikya@netbeans.org
Log: #143798 [65cat] Test for a connection before using it in SQL Editor