db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1450422 - in /db/derby/code/trunk/java: client/org/apache/derby/client/am/ client/org/apache/derby/jdbc/ engine/org/apache/derby/impl/jdbc/ engine/org/apache/derby/jdbc/ engine/org/apache/derby/mbeans/ testing/org/apache/derbyTesting/funct...
Date Tue, 26 Feb 2013 21:05:14 GMT
Author: rhillegas
Date: Tue Feb 26 21:05:14 2013
New Revision: 1450422

URL: http://svn.apache.org/r1450422
Log:
DERBY-6000: Fix misc issues raised by JDBC 4.2 buddy testing.

Modified:
    db/derby/code/trunk/java/client/org/apache/derby/client/am/Agent.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement42.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
    db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement42.java
    db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ConnectionChild.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java
    db/derby/code/trunk/java/engine/org/apache/derby/jdbc/JDBC.java
    db/derby/code/trunk/java/engine/org/apache/derby/mbeans/JDBCMBean.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/Agent.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/Agent.java?rev=1450422&r1=1450421&r2=1450422&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/Agent.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/Agent.java Tue Feb 26 21:05:14
2013
@@ -77,10 +77,13 @@ public abstract class Agent {
         switch (dataType) {
         case java.sql.Types.ARRAY:
         case java.sql.Types.DATALINK:
+        case java.sql.Types.DISTINCT:
         case JDBC40Translation.NCHAR:
         case JDBC40Translation.NCLOB:
         case JDBC40Translation.NVARCHAR:
         case JDBC40Translation.LONGNVARCHAR:
+        case java.sql.Types.NULL:
+        case java.sql.Types.OTHER:
         case java.sql.Types.REF:
         case JDBC40Translation.REF_CURSOR:
         case JDBC40Translation.ROWID:

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement42.java?rev=1450422&r1=1450421&r2=1450422&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement42.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/CallableStatement42.java Tue
Feb 26 21:05:14 2013
@@ -57,163 +57,133 @@ public class CallableStatement42 extends
     public  void registerOutParameter( int parameterIndex, SQLType sqlType )
         throws SQLException
     {
-        try
-        {
-            synchronized (connection_) {
-                if (agent_.loggingEnabled()) {
-                    agent_.logWriter_.traceEntry( this, "registerOutParameter", parameterIndex,
sqlType );
-                }
-                checkForClosedStatement();
-                registerOutParameter( parameterIndex, Utils42.getTypeAsInt( agent_, sqlType
) );
-            }
+        synchronized (connection_) {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry( this, "registerOutParameter", parameterIndex,
sqlType );
+            }
+            
+            checkStatus();
+            registerOutParameter( parameterIndex, Utils42.getTypeAsInt( agent_, sqlType )
);
         }
-        catch ( SqlException se )  { throw se.getSQLException(); }
     }
 
     public  void registerOutParameter( int parameterIndex, SQLType sqlType, int scale )
         throws SQLException
     {
-        try
-        {
-            synchronized (connection_) {
-                if (agent_.loggingEnabled()) {
-                    agent_.logWriter_.traceEntry( this, "registerOutParameter", parameterIndex,
sqlType, scale );
-                }
-                checkForClosedStatement();
-                registerOutParameter( parameterIndex, Utils42.getTypeAsInt( agent_, sqlType
), scale );
-            }
+        synchronized (connection_) {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry( this, "registerOutParameter", parameterIndex,
sqlType, scale );
+            }
+            
+            checkStatus();
+            registerOutParameter( parameterIndex, Utils42.getTypeAsInt( agent_, sqlType ),
scale );
         }
-        catch ( SqlException se )  { throw se.getSQLException(); }
     }
     
     public  void registerOutParameter( int parameterIndex, SQLType sqlType, String typeName
)
         throws SQLException
     {
-        try
-        {
-            synchronized (connection_) {
-                if (agent_.loggingEnabled()) {
-                    agent_.logWriter_.traceEntry( this, "registerOutParameter", parameterIndex,
sqlType, typeName );
-                }
-                checkForClosedStatement();
-                registerOutParameter( parameterIndex, Utils42.getTypeAsInt(agent_, sqlType
), typeName );
-            }
+        synchronized (connection_) {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry( this, "registerOutParameter", parameterIndex,
sqlType, typeName );
+            }
+            
+            checkStatus();
+            registerOutParameter( parameterIndex, Utils42.getTypeAsInt(agent_, sqlType ),
typeName );
         }
-        catch ( SqlException se )  { throw se.getSQLException(); }
     }
     
     public  void registerOutParameter( String parameterName, SQLType sqlType )
         throws SQLException
     {
-        try
-        {
-            synchronized (connection_) {
-                if (agent_.loggingEnabled()) {
-                    agent_.logWriter_.traceEntry( this, "registerOutParameter", parameterName,
sqlType );
-                }
-                checkForClosedStatement();
-                registerOutParameter( parameterName, Utils42.getTypeAsInt(agent_, sqlType
) );
-            }
+        synchronized (connection_) {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry( this, "registerOutParameter", parameterName,
sqlType );
+            }
+            
+            checkStatus();
+            registerOutParameter( parameterName, Utils42.getTypeAsInt(agent_, sqlType ) );
         }
-        catch ( SqlException se )  { throw se.getSQLException(); }
     }
     
     public  void registerOutParameter( String parameterName, SQLType sqlType, int scale )
         throws SQLException
     {
-        try
-        {
-            synchronized (connection_) {
-                if (agent_.loggingEnabled()) {
-                    agent_.logWriter_.traceEntry( this, "registerOutParameter", parameterName,
sqlType, scale );
-                }
-                checkForClosedStatement();
-                registerOutParameter( parameterName, Utils42.getTypeAsInt(agent_, sqlType
), scale );
-            }
+        synchronized (connection_) {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry( this, "registerOutParameter", parameterName,
sqlType, scale );
+            }
+            
+            checkStatus();
+            registerOutParameter( parameterName, Utils42.getTypeAsInt(agent_, sqlType ),
scale );
         }
-        catch ( SqlException se )  { throw se.getSQLException(); }
     }
     
     public  void registerOutParameter( String parameterName,  SQLType sqlType, String typeName
)
         throws SQLException
     {
-        try
-        {
-            synchronized (connection_) {
-                if (agent_.loggingEnabled()) {
-                    agent_.logWriter_.traceEntry( this, "registerOutParameter", parameterName,
sqlType, typeName );
-                }
-                checkForClosedStatement();
-                registerOutParameter( parameterName, Utils42.getTypeAsInt(agent_, sqlType
), typeName );
-            }
+        synchronized (connection_) {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry( this, "registerOutParameter", parameterName,
sqlType, typeName );
+            }
+            
+            checkStatus();
+            registerOutParameter( parameterName, Utils42.getTypeAsInt(agent_, sqlType ),
typeName );
         }
-        catch ( SqlException se )  { throw se.getSQLException(); }
     }
 
     public  void setObject
         ( int parameterIndex, java.lang.Object x, SQLType sqlType )
         throws SQLException
     {
-        try
-        {
-            synchronized (connection_) {
-                if (agent_.loggingEnabled()) {
-                    agent_.logWriter_.traceEntry( this, "setObject", parameterIndex, x, sqlType
);
-                }
-                checkForClosedStatement();
-                setObject( parameterIndex, x, Utils42.getTypeAsInt(agent_, sqlType ) );
-            }
+        synchronized (connection_) {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry( this, "setObject", parameterIndex, x, sqlType
);
+            }
+            
+            checkStatus();
+            setObject( parameterIndex, x, Utils42.getTypeAsInt(agent_, sqlType ) );
         }
-        catch ( SqlException se )  { throw se.getSQLException(); }
     }
     
     public void setObject
         ( int parameterIndex, java.lang.Object x, SQLType sqlType, int scaleOrLength )
         throws SQLException
     {
-        try
-        {
-            synchronized (connection_) {
-                if (agent_.loggingEnabled()) {
-                    agent_.logWriter_.traceEntry( this, "setObject", new Integer( parameterIndex
), x, sqlType, new Integer( scaleOrLength ) );
-                }
-                checkForClosedStatement();
-                setObject( parameterIndex, x, Utils42.getTypeAsInt(agent_, sqlType ), scaleOrLength
);
-            }
+        synchronized (connection_) {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry( this, "setObject", new Integer( parameterIndex
), x, sqlType, new Integer( scaleOrLength ) );
+            }
+            
+            checkStatus();
+            setObject( parameterIndex, x, Utils42.getTypeAsInt(agent_, sqlType ), scaleOrLength
);
         }
-        catch ( SqlException se )  { throw se.getSQLException(); }
     }
 
     public  void setObject( String parameterName, Object x, SQLType sqlType )
         throws SQLException
     {
-        try
-        {
-            synchronized (connection_) {
-                if (agent_.loggingEnabled()) {
-                    agent_.logWriter_.traceEntry( this, "setObject", parameterName, x, sqlType
);
-                }
-                checkForClosedStatement();
-                setObject( parameterName, x, Utils42.getTypeAsInt(agent_, sqlType ) );
-            }
+        synchronized (connection_) {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry( this, "setObject", parameterName, x, sqlType
);
+            }
+            
+            checkStatus();
+            setObject( parameterName, x, Utils42.getTypeAsInt(agent_, sqlType ) );
         }
-        catch ( SqlException se )  { throw se.getSQLException(); }
     }
     
     public  void setObject( String parameterName, Object x, SQLType sqlType, int scaleOrLength
)
         throws SQLException
     {
-        try
-        {
-            synchronized (connection_) {
-                if (agent_.loggingEnabled()) {
-                    agent_.logWriter_.traceEntry( this, "setObject", parameterName, x, sqlType,
scaleOrLength );
-                }
-                checkForClosedStatement();
-                setObject( parameterName, x, Utils42.getTypeAsInt(agent_, sqlType ), scaleOrLength
);
-            }
+        synchronized (connection_) {
+            if (agent_.loggingEnabled()) {
+                agent_.logWriter_.traceEntry( this, "setObject", parameterName, x, sqlType,
scaleOrLength );
+            }
+            
+            checkStatus();
+            setObject( parameterName, x, Utils42.getTypeAsInt(agent_, sqlType ), scaleOrLength
);
         }
-        catch ( SqlException se )  { throw se.getSQLException(); }
     }
 
 }

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java?rev=1450422&r1=1450421&r2=1450422&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement.java Tue
Feb 26 21:05:14 2013
@@ -3178,4 +3178,18 @@ public class PreparedStatement extends S
         }
         
     }
+    
+    /**
+     * <p>
+     * Check for closed statement and extract the SQLException if it is raised.
+     * </p>
+     */
+    protected void    checkStatus() throws SQLException
+    {
+        try {
+            checkForClosedStatement();
+        }
+        catch (SqlException se) { throw se.getSQLException(); }
+    }
+
 }

Modified: db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement42.java?rev=1450422&r1=1450421&r2=1450422&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement42.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/client/am/PreparedStatement42.java Tue
Feb 26 21:05:14 2013
@@ -103,17 +103,4 @@ public class  PreparedStatement42 extend
         }
     }
 
-    /**
-     * <p>
-     * Check for closed statement and extract the SQLException if it is raised.
-     * </p>
-     */
-    private void    checkStatus() throws SQLException
-    {
-        try {
-            checkForClosedStatement();
-        }
-        catch (SqlException se) { throw se.getSQLException(); }
-    }
-
 }

Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java?rev=1450422&r1=1450421&r2=1450422&view=diff
==============================================================================
--- db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java (original)
+++ db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java Tue Feb 26 21:05:14
2013
@@ -93,6 +93,9 @@ public class ClientDriver implements jav
     public java.sql.Connection connect(String url,
                                        java.util.Properties properties) throws java.sql.SQLException
{
         org.apache.derby.client.net.NetConnection conn;
+        
+        checkURLNotNull( url );
+
         try {    
             if (exceptionsOnLoadDriver__ != null) {
                 throw exceptionsOnLoadDriver__;
@@ -207,6 +210,9 @@ public class ClientDriver implements jav
     }
 
     public boolean acceptsURL(String url) throws java.sql.SQLException {
+
+        checkURLNotNull( url );
+        
         try
         {
             java.util.StringTokenizer urlTokenizer = 
@@ -219,6 +225,17 @@ public class ClientDriver implements jav
             throw se.getSQLException();
         }
     }
+    private void    checkURLNotNull( String url ) throws java.sql.SQLException
+    {
+        if ( url == null )
+        {
+            throw (new SqlException
+                (
+                 null, 
+                 new ClientMessageId( SQLState.MALFORMED_URL), "null"
+                 )).getSQLException();
+        }
+    }
 
     public java.sql.DriverPropertyInfo[] getPropertyInfo(String url,
                                                          java.util.Properties properties)
throws java.sql.SQLException {

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ConnectionChild.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ConnectionChild.java?rev=1450422&r1=1450421&r2=1450422&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ConnectionChild.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/ConnectionChild.java Tue Feb
26 21:05:14 2013
@@ -172,10 +172,13 @@ abstract class ConnectionChild {
         switch (dataType) {
         case Types.ARRAY:
         case Types.DATALINK:
+        case Types.DISTINCT:
         case JDBC40Translation.NCHAR:
         case JDBC40Translation.NCLOB:
         case JDBC40Translation.NVARCHAR:
         case JDBC40Translation.LONGNVARCHAR:
+        case Types.NULL:
+        case Types.OTHER:
         case Types.REF:
         case JDBC40Translation.REF_CURSOR:
         case JDBC40Translation.ROWID:

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java?rev=1450422&r1=1450421&r2=1450422&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/InternalDriver.java Tue Feb 26 21:05:14
2013
@@ -132,7 +132,8 @@ public abstract class InternalDriver imp
 	/*
 	** Methods from java.sql.Driver
 	*/
-	public boolean acceptsURL(String url) {
+	public boolean acceptsURL(String url) throws SQLException
+    {
 		return active && embeddedDriverAcceptsURL( url );
 	}
 
@@ -141,7 +142,13 @@ public abstract class InternalDriver imp
 	** don't accidentally boot Derby while answering the question "Can
 	** you handle this URL?"
 	*/
-	public static	boolean embeddedDriverAcceptsURL(String url) {
+	public static	boolean embeddedDriverAcceptsURL(String url) throws SQLException
+    {
+        if ( url == null )
+        {
+            throw Util.generateCsSQLException( SQLState.MALFORMED_URL, "null" );
+        }
+        
 		return
 		//	need to reject network driver's URL's
 		!url.startsWith(Attribute.JCC_PROTOCOL) && !url.startsWith(Attribute.DNC_PROTOCOL)
&&

Modified: db/derby/code/trunk/java/engine/org/apache/derby/jdbc/JDBC.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/jdbc/JDBC.java?rev=1450422&r1=1450421&r2=1450422&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/jdbc/JDBC.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/jdbc/JDBC.java Tue Feb 26 21:05:14 2013
@@ -21,6 +21,8 @@
 
 package org.apache.derby.jdbc;
 
+import java.sql.SQLException;
+
 import org.apache.derby.iapi.services.info.JVMInfo;
 import org.apache.derby.mbeans.JDBCMBean;
 
@@ -55,6 +57,7 @@ final class JDBC implements JDBCMBean
     }
     
     public boolean acceptsURL(String url)
+        throws SQLException
     {
         return driver.acceptsURL(url);
     }

Modified: db/derby/code/trunk/java/engine/org/apache/derby/mbeans/JDBCMBean.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/mbeans/JDBCMBean.java?rev=1450422&r1=1450421&r2=1450422&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/mbeans/JDBCMBean.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/mbeans/JDBCMBean.java Tue Feb 26 21:05:14
2013
@@ -21,6 +21,8 @@
 
 package org.apache.derby.mbeans;
 
+import java.sql.SQLException;
+
 /** 
  * Management and information for the embedded JDBC driver.
  * <P>
@@ -64,6 +66,6 @@ public interface JDBCMBean {
      * @return True if it supports it, false otherwise.
      * @see java.sql.Driver#acceptsURL(String)
      */
-    public boolean acceptsURL(String url);
+    public boolean acceptsURL(String url) throws SQLException;
 
 }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java?rev=1450422&r1=1450421&r2=1450422&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/PreparedStatementTest42.java
Tue Feb 26 21:05:14 2013
@@ -66,9 +66,13 @@ public class PreparedStatementTest42 ext
     {
         JDBCType.ARRAY,
         JDBCType.DATALINK,
+        JDBCType.DISTINCT,
+        JDBCType.LONGNVARCHAR,
         JDBCType.NCHAR,
         JDBCType.NCLOB,
+        JDBCType.NULL,
         JDBCType.NVARCHAR,
+        JDBCType.OTHER,
         JDBCType.REF,
         JDBCType.REF_CURSOR,
         JDBCType.ROWID,
@@ -229,6 +233,7 @@ public class PreparedStatementTest42 ext
         {
             try {
                 insert.setObject( 1, null, ILLEGAL_JDBC_TYPES[ i ] );
+                fail( "setObject() should have failed." );
             }
             catch (SQLException se) { assertUnimplemented( se ); }
         }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java?rev=1450422&r1=1450421&r2=1450422&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/UnsupportedVetter.java
Tue Feb 26 21:05:14 2013
@@ -814,7 +814,9 @@ public class UnsupportedVetter	extends B
             return new Short((short) 0);
         }
         if (type == Integer.TYPE) {
-            return new Integer(0);
+            // use 1 instead of 0. 0 = java.sql.Types.NULL and this causes
+            // various type-aware methods to raise SQLFeatureNotSupportedException
+            return new Integer(1);
         }
         if (type == Long.TYPE) {
             return new Long(0L);

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java?rev=1450422&r1=1450421&r2=1450422&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DriverTest.java
Tue Feb 26 21:05:14 2013
@@ -52,7 +52,9 @@ import junit.framework.TestSuite;
 public class DriverTest extends BaseJDBCTestCase {
 
     // DERBY-618 - Database name with spaces
-    private static String DB_NAME_WITH_SPACES = "db name with spaces";
+    private static final    String DB_NAME_WITH_SPACES = "db name with spaces";
+
+    private static  final   String  MALFORMED_URL = "XJ028";
     
     /**
      * Set of additional databases for tests that
@@ -222,6 +224,18 @@ public class DriverTest extends BaseJDBC
         // on Java 6 or higher
         println( "Driver is a " + driver.getClass().getName() );
         assertEquals( JDBC.vmSupportsJDBC4(), driver.getClass().getName().endsWith( "40"
) );
+
+        // test that null connection URLs raise a SQLException per JDBC 4.2 spec clarification
+        try {
+            driver.acceptsURL( null );
+            fail( "Should not have accepted a null connection url" );
+        }
+        catch (SQLException se) { assertSQLState( MALFORMED_URL, se ); }
+        try {
+            driver.connect( null, props );
+            fail( "Should not have accepted a null connection url" );
+        }
+        catch (SQLException se) { assertSQLState( MALFORMED_URL, se ); }
         
         conn.close();
     }



Mime
View raw message