You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Stan Bradbury (JIRA)" <ji...@apache.org> on 2007/11/02 02:26:50 UTC

[jira] Created: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error it thrown

ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error it thrown
------------------------------------------------------------------------------------------------------

                 Key: DERBY-3172
                 URL: https://issues.apache.org/jira/browse/DERBY-3172
             Project: Derby
          Issue Type: Bug
          Components: JDBC
    Affects Versions: 10.3.1.4
            Reporter: Stan Bradbury
         Attachments: DerbyNotification2.java

The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.

Program also demonstrates that the connectionClosed method is executed when the connection is closed.

To run the reproduction:
1) start network server (listening on default host/port and  -noSecurityManager specified)
2) run the program

Output is:
 > java DerbyNotification2
10.3.1.5 - (579866)

Apache Derby
 .got connection...check if connectionClosed method is called
EVENT CALLED: Connection closed happened
 . . .
 . . .Get connection and issue test SQL statement
 . . .AS EXPECTED: no table exists
 . SHUTDOWN Network server and check if connectionErrorOccurred is called
now try to use the connection after the NS is STOPPED
SQLState is: 08006
Error is: -4499
Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
        at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
        at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
        at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
        at DerbyNotification2.runTest(DerbyNotification2.java:64)
        at DerbyNotification2.main(DerbyNotification2.java:87)
Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
ted.
        at org.apache.derby.client.net.Reply.fill(Unknown Source)
        at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
        at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
        at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
        at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
        at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
        at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
        at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
        at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
        at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
        at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
        at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
        ... 4 more


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Manjula Kutty (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12540925 ] 

Manjula Kutty commented on DERBY-3172:
--------------------------------------

There is this test called ShutdownDatabaseTest.java in lang which does the shutdown of derby engine.

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12540862 ] 

Mamta A. Satoor commented on DERBY-3172:
----------------------------------------

I investigated this Jira issue and following is what I found along with a proposed solution at the end.

Consider following piece of code In embedded mode, 
      EmbeddedConnectionPoolDataSource ds =
         new EmbeddedConnectionPoolDataSource();
      ((EmbeddedConnectionPoolDataSource)ds).setDatabaseName("c:/dellater/derby_3172_embedded;create=true");

        PooledConnection pooledCon = ds.getPooledConnection();
        pooledCon.addConnectionEventListener(this);
        Connection conn = pooledCon.getConnection();

        try
        {
                Class.forName("org.apache.derby.jdbc.EmbeddedDriver"); 
                String url = "jdbc:derby:c:/dellater/derby_3172_embedded;shutdown=true";
                Connection c = DriverManager.getConnection(url);        		
        }
        catch (Exception e)
        {
               System.out.println("Exception shutting down Network Server");
        }

The shutdown above throws"Database 'c:/dellater/derby_3172_embedded' shutdown." exception but the connection event listener does not get any events at this point. Continuing the eg above with following 
        PrepareStatement ps1 = conn.prepareStatement("CREATE TABLE TAB1(COL1 INT NOT NULL)");
The above statement throws an exception(SQLState 08003 No current connection.). But before throwing the exception, the connection event listener gets an event about connection error. This part is missing when similar code is tried in Network Server.

Consider similar eg for Network Server code
        ClientConnectionPoolDataSource ds =
             new ClientConnectionPoolDataSource();
         ((ClientConnectionPoolDataSource)ds).setDatabaseName("c:/dellater/derby_3172_embedded;create=true");

        PooledConnection pooledCon = ds.getPooledConnection();
        pooledCon.addConnectionEventListener(this);
        Connection conn = pooledCon.getConnection();

        NetworkServerControl server = new NetworkServerControl();
        server.shutdown();        		
        PrepareStatement ps1 = conn.prepareStatement("CREATE TABLE TAB1(COL1 INT NOT NULL)");
When the code above is run in Network Server mode, shutdown of Network Server does not throw any exception to the client. But when the program gets to conn.prepareStatement, following exception(SQLState 08006) is thrown as expected
	A communications error has been detected: Software caused connection abort: recv failed.
*****But no connection event error is received by the connection event listener. *****

The difference in code that I find between client driver and embedded driver is following
iapi.jdbc.BrokeredConnection in embedded catches the exception about no current connection and notifies the listeners as follows
	public final PreparedStatement prepareStatement(String sql)
	    throws SQLException 
	{
		try {
			return control.wrapStatement(getRealConnection().prepareStatement(sql), sql, null);
		} catch (SQLException sqle) {
			notifyException(sqle);
			throw sqle;
		}
	}

But on the client side in client.am.LogicalConnection has following code (ie it does not do anything with SQLException that it receives)
    synchronized public java.sql.PreparedStatement prepareStatement(String sql) throws SQLException {
        checkForNullPhysicalConnection();
        return physicalConnection_.prepareStatement(sql);
    }

I think to solve the problem, we need to have try catch in prepareStatement method on the client side and send event to the listeners through pooledConnection_. We do something similar in close() method on the client side. I think this needs to be done for all JDBC methods implemented in client.am.LogicalConnection. Let me know if anyone has any thoughts on this approach. I will start looking at implementing this soon.

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Issue Comment Edited: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12543190 ] 

mamtas edited comment on DERBY-3172 at 11/26/07 11:01 PM:
-------------------------------------------------------------------

Just committed a change into trunk through 595803 which should take care of DataSourceTest failure. The commit comments are as follows

This is a followup checkin to checkin(595047) was committed for DERBY-3172. The DataSourceTest had started failing under JDK1.6 after 595047. The particular test case that was failing was for Connection.getTypeMap The reason for failure was that this method was overridden in a subclass which kicks in only when JDBC4.0 is available. The overriden method was not sending the correct connection error event as expected by the test and hence the failure. While fixing this, I realized that there are several new JDBC4.0 apis that need to send the correct events to ConnectionEventListeners. This checkin takes care of those apis. More info on what was changed in this commit is as follows.

New JDBC4.0 api, setClientInfo, wraps SQLException inside SQLClientInfoException but we were not copying the error code of SQLException into SQLClientInfoException. Without the correct error code, we would not send connection error event because the severity has to be fatal for us to send connection error event. Because of this, I had to change several places where SQLException is wrapped inside SQLClientInfoException to pass SQLException's error code to SQLClientInfoException. The classes changed because of this are EmbedConnection40, BrokeredConnection40, NetConnection40.

For methods that throw SQLClientInfoException, we were not notifying the connection error events. I made changes to fix this.

Several of new JDBC4 apis on connection object were not sending error events so I changed those methods in BrokeredConnection40 and LogicalConnection40. 

BrokeredConnection40 implements new JDBC4 methods on Connection object but these new methods did not follow the same logic as the other existing pre-JDBC4 methods to check for connection close and that caused the events to be not sent correctly. The problematic apis were createBlob, createClob, isWrapperFor, unwrap and I fixed those.

Not all the new JDBC4 apis have been implemented (they throw not implemented exception) so the tests written for those apis just catch the unimplemented exception. These methods include createArrayOf, createNClob, createSQLXML, createStruct.

In JDBC4, Connection object has two methods isWrapperFor and unwrap which do not go to the server when Derby is being accessed in client server mode and because of this, we never detect that the server is down and hence no connection error event is thrown in client server mode for these 2 apis. But when the same apis are called in embedded Derby after the engine is shutdown, we get connection error event. I have added the test for these 2 apis to count for the different in behavior but I am not sure if this is the expected behavior difference between the 2 configurations of Derby. I will enter a Jira entry for this.

And lastly, the new JDBC4 api isValid on Connection object has different behavior in client server mode and embedded mode. They both throw exception that the connection is down but the connection close and error events are not dealt the same way in the 2 configurations. In embedded mode, after the engine is shutdown, an isValid call on Connection object raises a connection closed event and no connection error event. In client server mode, after the Network Server is shutdown, an isValid call on Connection object does not raise any event. In both the configurations, we do get a SQLException stating that connection is down. Again, I am not sure if this is expected bahavior difference between the 2 configurations of Derby. I will enter a Jira entry for this too. In addition, as per Connection.isValid api Java specification, a SQLException is thrown under following condition which is not being followed in embedded and client-server mode
Throws: 
SQLException - if the value supplied for timeout is less then 0
Based on this, I am not sure if our behavior is correct to throw an SQLException if the server/engine is down. I will include this information in the Jira entry that I will make.

The tests for all these new JDBC4 apis are in jdbc4/DataSourceTest.  

I moved the AssertEventCatcher class implementation from jdbcapi/DataSourceTest into a class of it's own. This way, it can be shared by jdbcapi/DataSourceTest and jdbc4/DataSourceTest.

      was (Author: mamtas):
    Just committed a change into trunk through 595803 which should take care of DataSourceTest failure. The commit comments are as follows

This is a followup checkin to checkin(595050) was committed for DERBY-3172. The DataSourceTest had started failing under JDK1.6 after 595050. The particular test case that was failing was for Connection.getTypeMap The reason for failure was that this method was overridden in a subclass which kicks in only when JDBC4.0 is available. The overriden method was not sending the correct connection error event as expected by the test and hence the failure. While fixing this, I realized that there are several new JDBC4.0 apis that need to send the correct events to ConnectionEventListeners. This checkin takes care of those apis. More info on what was changed in this commit is as follows.

New JDBC4.0 api, setClientInfo, wraps SQLException inside SQLClientInfoException but we were not copying the error code of SQLException into SQLClientInfoException. Without the correct error code, we would not send connection error event because the severity has to be fatal for us to send connection error event. Because of this, I had to change several places where SQLException is wrapped inside SQLClientInfoException to pass SQLException's error code to SQLClientInfoException. The classes changed because of this are EmbedConnection40, BrokeredConnection40, NetConnection40.

For methods that throw SQLClientInfoException, we were not notifying the connection error events. I made changes to fix this.

Several of new JDBC4 apis on connection object were not sending error events so I changed those methods in BrokeredConnection40 and LogicalConnection40. 

BrokeredConnection40 implements new JDBC4 methods on Connection object but these new methods did not follow the same logic as the other existing pre-JDBC4 methods to check for connection close and that caused the events to be not sent correctly. The problematic apis were createBlob, createClob, isWrapperFor, unwrap and I fixed those.

Not all the new JDBC4 apis have been implemented (they throw not implemented exception) so the tests written for those apis just catch the unimplemented exception. These methods include createArrayOf, createNClob, createSQLXML, createStruct.

In JDBC4, Connection object has two methods isWrapperFor and unwrap which do not go to the server when Derby is being accessed in client server mode and because of this, we never detect that the server is down and hence no connection error event is thrown in client server mode for these 2 apis. But when the same apis are called in embedded Derby after the engine is shutdown, we get connection error event. I have added the test for these 2 apis to count for the different in behavior but I am not sure if this is the expected behavior difference between the 2 configurations of Derby. I will enter a Jira entry for this.

And lastly, the new JDBC4 api isValid on Connection object has different behavior in client server mode and embedded mode. They both throw exception that the connection is down but the connection close and error events are not dealt the same way in the 2 configurations. In embedded mode, after the engine is shutdown, an isValid call on Connection object raises a connection closed event and no connection error event. In client server mode, after the Network Server is shutdown, an isValid call on Connection object does not raise any event. In both the configurations, we do get a SQLException stating that connection is down. Again, I am not sure if this is expected bahavior difference between the 2 configurations of Derby. I will enter a Jira entry for this too. In addition, as per Connection.isValid api Java specification, a SQLException is thrown under following condition which is not being followed in embedded and client-server mode
Throws: 
SQLException - if the value supplied for timeout is less then 0
Based on this, I am not sure if our behavior is correct to throw an SQLException if the server/engine is down. I will include this information in the Jira entry that I will make.

The tests for all these new JDBC4 apis are in jdbc4/DataSourceTest.  

I moved the AssertEventCatcher class implementation from jdbcapi/DataSourceTest into a class of it's own. This way, it can be shared by jdbcapi/DataSourceTest and jdbc4/DataSourceTest.
  
> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12541091 ] 

Mamta A. Satoor commented on DERBY-3172:
----------------------------------------

While working on this issue, I found that when a JCBC Connection is already closed and user attempts to close it again, in embedded mode, the driver simply returns from the method **without** sending a notification to the ConnectionEventListener. Following is the code for close() in iapi.jdbc.BrokeredConnection
public final void close() throws SQLException 
{ 
	if (isClosed)
		return;
	try {
		if (!control.closingConnection()) {
			isClosed = true;
			return;
		}
		isClosed = true;

		getRealConnection().close();
	} catch (SQLException sqle) {
		notifyException(sqle);
		throw sqle;
	}
}

But in the client driver side, if a Connection object is already closed, then next attempt to close it send connectionErrorOccurred to the listeners.  Following is the code for close() in client.am.LogicalConnection
    synchronized public void close() throws SQLException {
        try
        {
            // we also need to loop thru all the logicalStatements and close them
            if (physicalConnection_ == null) {
                return;
            }
            if (physicalConnection_.agent_.loggingEnabled()) {
                physicalConnection_.agent_.logWriter_.traceEntry(this, "close");
            }

            if (physicalConnection_.isClosed()) // connection is closed or has become stale
            {
                pooledConnection_.trashConnection(new SqlException(null, 
                    new ClientMessageId(
                        SQLState.PHYSICAL_CONNECTION_ALREADY_CLOSED)));
            } else {
                physicalConnection_.closeForReuse();
                if (!physicalConnection_.isGlobalPending_()) {
                    pooledConnection_.recycleConnection();
                }
            }
            physicalConnection_ = null;
            pooledConnection_.nullLogicalConnection();
        }
        catch ( SqlException se )
        {
            throw se.getSQLException();
        }
    }


I am not sure why we have this difference in behavior between the 2 drivers. I will make the client driver match the behavior of embedded driver ie do not send any events if close is being called on a closed Connection object. Please let me know if anyone has objections to this.

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Assigned: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mamta A. Satoor reassigned DERBY-3172:
--------------------------------------

    Assignee: Mamta A. Satoor

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Stan Bradbury (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stan Bradbury closed DERBY-3172.
--------------------------------


Catching up on Closing my reported issues.  Thanks to Dyre for the workflow reminder today.

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>             Fix For: 10.3.2.1, 10.4.0.0
>
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12540934 ] 

Mamta A. Satoor commented on DERBY-3172:
----------------------------------------

Thanks, Manjula. I will look at it for embedded test case.

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Knut Anders Hatlen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12542716 ] 

Knut Anders Hatlen commented on DERBY-3172:
-------------------------------------------

Seems like the Tinderbox was broken by this commit. http://dbtg.thresher.com/derby/test/tinderbox_trunk16/jvm1.6/testing/Limited/testSummary-595050.html

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error it thrown

Posted by "Stan Bradbury (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stan Bradbury updated DERBY-3172:
---------------------------------

    Attachment: DerbyNotification2.java

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error it thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12542592 ] 

Mamta A. Satoor commented on DERBY-3172:
----------------------------------------

Commited(revision 595047) the changes into trunk codeline with following commit comments

DERBY-3172

Change the Network Server code so that when the Network Server is shutdown, any api on Connection object will raise a Connection error event (similar to what is done in embedded mode). This also required me changing the disconnectError from -4999 to 40000(to match embedded). This change was made client.am.SqlCode. I have added tests for all the apis on Connection object in DataSourceTest. Had to change couple tests which were testing for -4999. Now they look for 40000. I will merge this change into 10.3 and run tests there before committing the changes in 10.3 codeline.

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Kathey Marsden (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12541170 ] 

Kathey Marsden commented on DERBY-3172:
---------------------------------------

I had thought in 10.2 we had changed the client error codes to match embedded but apparently not.  The code -4499 I don't believe has anything to do with DRDA, but is just the code used by client for disconnect exceptions.  Options are:
1) To change that code to match embedded SESSION_LEVEL severity
2) To trigger a connectionError event for the -4499 exception.

I tend to think 1 might be a good option for trunk but is too risky for the 10.3 branch. There I think 2 would be more appropriate.

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12541161 ] 

Mamta A. Satoor commented on DERBY-3172:
----------------------------------------

On further investigation, it seems that in client server mode, we are changing the exception's severity code from session severity to some DRDA severity and that causes the connection error event to not trigger even with my local code changes. 

The exception that gets thrown when Network Server is down is 
    String COMMUNICATION_ERROR                                  = "08006.C.3";
derby,shared.common.error.ExceptionUtil.java uses 08006 and determines the severity code to be session severity. So far so good. But later derby.client.am.SqlException changes the severity code to  disconnectError which is defined as new SqlCode(-4499) in client,am.SqlCode

    public SqlException(LogWriter logWriter, ClientMessageId msgid, Object[] args,
        SqlCode sqlcode, Throwable t) {
        this(logWriter, msgid, args, t);
        this.errorcode_ = sqlcode.getCode();
    }

So the cause of the problem is this change of severity code. Does anyone know why do we overwrite the severity code determined based on 08006 to a completely different value.

I need to run pickup my daughter so if this information looks incomplete or if I can provide further information, let me know and I will post something later tonight.,

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12543190 ] 

Mamta A. Satoor commented on DERBY-3172:
----------------------------------------

Just committed a change into trunk through 595803 which should take care of DataSourceTest failure. The commit comments are as follows

This is a followup checkin to checkin(595050) was committed for DERBY-3172. The DataSourceTest had started failing under JDK1.6 after 595050. The particular test case that was failing was for Connection.getTypeMap The reason for failure was that this method was overridden in a subclass which kicks in only when JDBC4.0 is available. The overriden method was not sending the correct connection error event as expected by the test and hence the failure. While fixing this, I realized that there are several new JDBC4.0 apis that need to send the correct events to ConnectionEventListeners. This checkin takes care of those apis. More info on what was changed in this commit is as follows.

New JDBC4.0 api, setClientInfo, wraps SQLException inside SQLClientInfoException but we were not copying the error code of SQLException into SQLClientInfoException. Without the correct error code, we would not send connection error event because the severity has to be fatal for us to send connection error event. Because of this, I had to change several places where SQLException is wrapped inside SQLClientInfoException to pass SQLException's error code to SQLClientInfoException. The classes changed because of this are EmbedConnection40, BrokeredConnection40, NetConnection40.

For methods that throw SQLClientInfoException, we were not notifying the connection error events. I made changes to fix this.

Several of new JDBC4 apis on connection object were not sending error events so I changed those methods in BrokeredConnection40 and LogicalConnection40. 

BrokeredConnection40 implements new JDBC4 methods on Connection object but these new methods did not follow the same logic as the other existing pre-JDBC4 methods to check for connection close and that caused the events to be not sent correctly. The problematic apis were createBlob, createClob, isWrapperFor, unwrap and I fixed those.

Not all the new JDBC4 apis have been implemented (they throw not implemented exception) so the tests written for those apis just catch the unimplemented exception. These methods include createArrayOf, createNClob, createSQLXML, createStruct.

In JDBC4, Connection object has two methods isWrapperFor and unwrap which do not go to the server when Derby is being accessed in client server mode and because of this, we never detect that the server is down and hence no connection error event is thrown in client server mode for these 2 apis. But when the same apis are called in embedded Derby after the engine is shutdown, we get connection error event. I have added the test for these 2 apis to count for the different in behavior but I am not sure if this is the expected behavior difference between the 2 configurations of Derby. I will enter a Jira entry for this.

And lastly, the new JDBC4 api isValid on Connection object has different behavior in client server mode and embedded mode. They both throw exception that the connection is down but the connection close and error events are not dealt the same way in the 2 configurations. In embedded mode, after the engine is shutdown, an isValid call on Connection object raises a connection closed event and no connection error event. In client server mode, after the Network Server is shutdown, an isValid call on Connection object does not raise any event. In both the configurations, we do get a SQLException stating that connection is down. Again, I am not sure if this is expected bahavior difference between the 2 configurations of Derby. I will enter a Jira entry for this too. In addition, as per Connection.isValid api Java specification, a SQLException is thrown under following condition which is not being followed in embedded and client-server mode
Throws: 
SQLException - if the value supplied for timeout is less then 0
Based on this, I am not sure if our behavior is correct to throw an SQLException if the server/engine is down. I will include this information in the Jira entry that I will make.

The tests for all these new JDBC4 apis are in jdbc4/DataSourceTest.  

I moved the AssertEventCatcher class implementation from jdbcapi/DataSourceTest into a class of it's own. This way, it can be shared by jdbcapi/DataSourceTest and jdbc4/DataSourceTest.

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12542805 ] 

Mamta A. Satoor commented on DERBY-3172:
----------------------------------------

The test runs fine on my machine, not sure why it failed on Tinderbox. I am looking into it. Thanks for the headsup, Knut.

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Re: [jira] Commented: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Dag H. Wanvik" <Da...@Sun.COM>.
"Mamta A. Satoor (JIRA)" <ji...@apache.org> writes:

>     [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12542824 ] 
>
> Mamta A. Satoor commented on DERBY-3172:
> ----------------------------------------
>
> It appears that the test fails in Sun's jdk16 but passes on Sun's
> jdk142. I am not sure why. I will keep looking into it.

I can confirm this. It fails in my sandbox as well using Sun JDK 16.

Dag


[jira] Commented: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12542824 ] 

Mamta A. Satoor commented on DERBY-3172:
----------------------------------------

It appears that the test fails in Sun's jdk16 but passes on Sun's jdk142. I am not sure why. I will keep looking into it.

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12541095 ] 

Mamta A. Satoor commented on DERBY-3172:
----------------------------------------

After a quick talk with Dan, I realize that the embedded driver behavior is correct. The JDBC api for close() says "Calling the method close on a Connection object that is already closed is a no-op." And that is what the embedded driver is doing. 

I will go ahead and change the client's behavior so that we do not send any connection error event when close is called on a closed connection object.

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Stan Bradbury (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stan Bradbury updated DERBY-3172:
---------------------------------

    Summary: ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown  (was: ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error it thrown)

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12541383 ] 

Mamta A. Satoor commented on DERBY-3172:
----------------------------------------

Thanks for your input Kathey. I am leaning more towards option 1 in both trunk and 10.3 codeline to keep the codeline consistent as much as possible. Let me know if anyone feels strongly about not using option 2 or some other solution.

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12540896 ] 

Mamta A. Satoor commented on DERBY-3172:
----------------------------------------

I was thinking about junit testing for the proposed fix and having 2 test cases. 1)For Network Server, shutdown the database and see if listener gets the connection error event when the user tries to communicate to Network Server 2)Shutdown Derby engine and see if the listener gets the connection error event when the user tries to talk to Derby engine.

I was wondering how would I shut down the Network server and Derby engine inside junit framework. Maybe some of the existing junit tests do that already. I will try to hunt them down. But in the mean time, if someone knows how to shut down the Network server and Derby engine inside junit framework, I would appreciate that information.

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12546886 ] 

Mamta A. Satoor commented on DERBY-3172:
----------------------------------------

Entered jira entry DERBY-3237 for difference in behavior between network server and embedded for 3 JDBC4.0 apis on Connection object.

> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>             Fix For: 10.3.1.5, 10.4.0.0
>
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (DERBY-3172) ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown

Posted by "Mamta A. Satoor (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-3172?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mamta A. Satoor resolved DERBY-3172.
------------------------------------

       Resolution: Fixed
    Fix Version/s: 10.4.0.0
                   10.3.1.5

Merged changes into 10.3 codeline with revision 598712 and the commit comments were as follows


This commit merges into 10.3 codeline the 2 changes that went into trunk (595047 and 595803) for DERBY-3172.

I had to modify the merged code for the 2 test files by adding code to start and stop network server in jdbcapi.DataSourceTest and jdbc4.DataSourceTest.

In the trunk, these 2 functionalities of start and stop of network server are already available in the TestConfiguration.java. This functionalities were added into trunk as part of checkin 574053 for DERBY-2855. I could merge the changes that went into  TestConfiguration to introduce these 2 functionalities in 10.3 codeline but there is an outstanding jira issue about this functionality causing derbynet.jar dependency. The jira issue is DERBY-3151 "Reduce dependency on NetworkServerControl in TestConfiguration" Because of this, I opted to add start and stop network server functionality in jdbcapi.DataSourceTest and jdbc4.DataSourceTest. I have updated DERBY-3151 requesting that once we reach a resolution, we should migrate the changes into 10.3 codeline too so that individual tests requiring start and stop network server do not have to write the code themselves, instead they can depend on the TestConfiguration.java or some other class to provide that functionality. Once that work is done, jdbcapi.DataSourceTest and jdbc4.DataSourceTest should be modified. I think in addition to these 2 tests, OutBufferedStream.java and TestConnectionMethods.java also have start and stop network server code in 10.3 codeline.



> ConnectionEventListener.connectionErrorOccurred not being executed when SQLState 08006 Error is thrown
> ------------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-3172
>                 URL: https://issues.apache.org/jira/browse/DERBY-3172
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.1.4
>            Reporter: Stan Bradbury
>            Assignee: Mamta A. Satoor
>             Fix For: 10.3.1.5, 10.4.0.0
>
>         Attachments: DerbyNotification2.java
>
>
> The attached program demonstrates the problem.  Using the ClientConnectionPoolDataSource40 with a connectionEventListener the defined method connectionErrorOccurred is not executed after the Network Server is shutdown and activity is performed on a previously established pooled connection.
> Program also demonstrates that the connectionClosed method is executed when the connection is closed.
> To run the reproduction:
> 1) start network server (listening on default host/port and  -noSecurityManager specified)
> 2) run the program
> Output is:
>  > java DerbyNotification2
> 10.3.1.5 - (579866)
> Apache Derby
>  .got connection...check if connectionClosed method is called
> EVENT CALLED: Connection closed happened
>  . . .
>  . . .Get connection and issue test SQL statement
>  . . .AS EXPECTED: no table exists
>  . SHUTDOWN Network server and check if connectionErrorOccurred is called
> now try to use the connection after the NS is STOPPED
> SQLState is: 08006
> Error is: -4499
> Message is: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been terminated.
> Exception in thread "main" java.sql.SQLNonTransientConnectionException: 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(Unknown Source)
>         at org.apache.derby.client.am.SqlException.getSQLException(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatement(Unknown Source)
>         at org.apache.derby.client.am.LogicalConnection.prepareStatement(Unknown Source)
>         at DerbyNotification2.runTest(DerbyNotification2.java:64)
>         at DerbyNotification2.main(DerbyNotification2.java:87)
> Caused by: org.apache.derby.client.am.DisconnectException: Insufficient data while reading from the network - expected a minimum of 6 bytes and received only -1 bytes.  The connection has been termina
> ted.
>         at org.apache.derby.client.net.Reply.fill(Unknown Source)
>         at org.apache.derby.client.net.Reply.ensureALayerDataInBuffer(Unknown Source)
>         at org.apache.derby.client.net.Reply.readDssHeader(Unknown Source)
>         at org.apache.derby.client.net.Reply.startSameIdChainParse(Unknown Source)
>         at org.apache.derby.client.net.NetStatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.StatementReply.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.net.NetStatement.readPrepareDescribeOutput_(Unknown Source)
>         at org.apache.derby.client.am.Statement.readPrepareDescribeOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.readPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.flowPrepareDescribeInputOutput(Unknown Source)
>         at org.apache.derby.client.am.PreparedStatement.prepare(Unknown Source)
>         at org.apache.derby.client.am.Connection.prepareStatementX(Unknown Source)
>         ... 4 more

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.