Incorrectly specifying database name with JDBC protocol causes unhelpful error 
message in client data sources
-------------------------------------------------------------------------------------------------------------

                 Key: DERBY-3407
                 URL: https://issues.apache.org/jira/browse/DERBY-3407
             Project: Derby
          Issue Type: Bug
          Components: JDBC, Network Client
    Affects Versions: 10.4.0.0
            Reporter: Kristian Waagan
            Priority: Minor


If the database name is specified with the JDBC protocol, the user is presented 
with very unhelpful error messages.
On the embedded side, a meaningful error message is produced and presented to 
the user.
Even though specifying the JDBC protocol can be classified as a user error, it 
would be good if Derby gave a meaningful hint for what is wrong.

For instance:
cp.setDatabaseName("jdbc:derby://localhost/kwTestDB");
cp.get(Pooled|XA)Connection();

** For ClientPooledConnectionDataSource and ClientDataSource
Exception in thread "main" java.lang.NullPointerException
        at org.apache.derby.client.am.ProductLevel.<init>(ProductLevel.java:41)
        at 
org.apache.derby.client.net.NetDatabaseMetaData.<init>(NetDatabaseMetaData.java:40)
        at 
org.apache.derby.client.net.NetDatabaseMetaData40.<init>(NetDatabaseMetaData40.java:36)
        at 
org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newNetDatabaseMetaData(ClientJDBCObjectFactoryImpl40.java:318)
        at 
org.apache.derby.client.net.NetConnection.newDatabaseMetaData_(NetConnection.java:1144)
        at 
org.apache.derby.client.am.Connection.completeConnect(Connection.java:1822)
        at 
org.apache.derby.client.net.NetConnection.completeConnect(NetConnection.java:412)
        at 
org.apache.derby.client.net.NetConnection.initialize(NetConnection.java:297)
        at 
org.apache.derby.client.net.NetConnection.<init>(NetConnection.java:231)
        at 
org.apache.derby.client.net.NetConnection40.<init>(NetConnection40.java:85)
        at 
org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newNetConnection(ClientJDBCObjectFactoryImpl40.java:255)
        at 
org.apache.derby.jdbc.ClientDataSource.getConnection(ClientDataSource.java:186)
        at 
org.apache.derby.jdbc.ClientDataSource.getConnection(ClientDataSource.java:163)

** For ClientXADataSource
Exception in thread "main" java.sql.SQLException: DERBY SQL error: SQLCODE: -1, 
SQLSTATE: XCY00, SQLERRMC: databaseNamejdbc:derby://localhost/kwTestDBXCY00.S
        at 
org.apache.derby.client.am.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:96)
        at 
org.apache.derby.client.am.SqlException.getSQLException(SqlException.java:362)
        at 
org.apache.derby.client.ClientPooledConnection.<init>(ClientPooledConnection.java:150)
        at 
org.apache.derby.client.ClientXAConnection.<init>(ClientXAConnection.java:48)
        at 
org.apache.derby.client.ClientXAConnection40.<init>(ClientXAConnection40.java:57)
        at 
org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newClientXAConnection(ClientJDBCObjectFactoryImpl40.java:94)
        at 
org.apache.derby.jdbc.ClientXADataSource.getXAConnectionX(ClientXADataSource.java:88)
        at 
org.apache.derby.jdbc.ClientXADataSource.getXAConnection(ClientXADataSource.java:72)
        at 
org.apache.derby.jdbc.ClientXADataSource.getXAConnection(ClientXADataSource.java:65)
        at KWPreparedStatementTest.main(KWPreparedStatementTest.java:37)
Caused by: org.apache.derby.client.am.SqlException: DERBY SQL error: SQLCODE: 
-1, SQLSTATE: XCY00, SQLERRMC: 
databaseNamejdbc:derby://localhost/kwTestDBXCY00.S
        at 
org.apache.derby.client.am.Connection.completeSqlca(Connection.java:1953)
        at 
org.apache.derby.client.net.NetConnectionReply.parseRdbAccessFailed(NetConnectionReply.java:549)
        at 
org.apache.derby.client.net.NetConnectionReply.parseAccessRdbError(NetConnectionReply.java:442)
        at 
org.apache.derby.client.net.NetConnectionReply.parseACCRDBreply(NetConnectionReply.java:306)
        at 
org.apache.derby.client.net.NetConnectionReply.readAccessDatabase(NetConnectionReply.java:133)
        at 
org.apache.derby.client.net.NetConnection.readSecurityCheckAndAccessRdb(NetConnection.java:887)
        at 
org.apache.derby.client.net.NetConnection.flowSecurityCheckAndAccessRdb(NetConnection.java:799)
        at 
org.apache.derby.client.net.NetConnection.flowUSRIDONLconnect(NetConnection.java:632)
        at 
org.apache.derby.client.net.NetConnection.flowConnect(NetConnection.java:439)
        at 
org.apache.derby.client.net.NetConnection.initialize(NetConnection.java:296)
        at 
org.apache.derby.client.net.NetConnection.<init>(NetConnection.java:280)
        at 
org.apache.derby.client.net.NetConnection40.<init>(NetConnection40.java:125)
        at 
org.apache.derby.client.net.ClientJDBCObjectFactoryImpl40.newNetConnection(ClientJDBCObjectFactoryImpl40.java:293)
        at 
org.apache.derby.client.net.NetXAConnection.createNetConnection(NetXAConnection.java:269)
        at 
org.apache.derby.client.net.NetXAConnection.<init>(NetXAConnection.java:73)
        at 
org.apache.derby.client.ClientPooledConnection.getNetXAConnection(ClientPooledConnection.java:395)
        at 
org.apache.derby.client.ClientPooledConnection.<init>(ClientPooledConnection.java:143)


** Finally, at least for EmddedConnectionPoolDataSource
Exception in thread "main" java.sql.SQLException: Invalid value for property 
'databaseName'='jdbc:derby:kwTestDB'.
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:95)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:88)
        at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Util.java:94)
        at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Util.java:180)
        at 
org.apache.derby.jdbc.EmbeddedDataSource.getConnection(EmbeddedDataSource.java:483)
        at 
org.apache.derby.jdbc.EmbedPooledConnection.openRealConnection(EmbedPooledConnection.java:171)
        at 
org.apache.derby.jdbc.EmbedPooledConnection.<init>(EmbedPooledConnection.java:113)
        at 
org.apache.derby.jdbc.EmbedPooledConnection40.<init>(EmbedPooledConnection40.java:52)
        at 
org.apache.derby.jdbc.Driver40.getNewPooledConnection(Driver40.java:176)
        at 
org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource.createPooledConnection(EmbeddedConnectionPoolDataSource.java:129)
        at 
org.apache.derby.jdbc.EmbeddedConnectionPoolDataSource.getPooledConnection(EmbeddedConnectionPoolDataSource.java:75)
        at KWPreparedStatementTest.main(KWPreparedStatementTest.java:35)
Caused by: java.sql.SQLException: Invalid value for property 
'databaseName'='jdbc:derby:kwTestDB'.
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(SQLExceptionFactory.java:45)
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(SQLExceptionFactory40.java:135)
        at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(SQLExceptionFactory40.java:70)
        ... 11 more


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

Reply via email to