db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmars...@apache.org
Subject svn commit: r382917 - in /db/derby/code/trunk/java: client/org/apache/derby/jdbc/ testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/master/DerbyNet/ testing/org/apache/derbyTesting/functionTests/master/...
Date Fri, 03 Mar 2006 19:51:48 GMT
Author: kmarsden
Date: Fri Mar  3 11:51:46 2006
New Revision: 382917

URL: http://svn.apache.org/viewcvs?rev=382917&view=rev
Log:
DERBY-618 Make the client driver connection URL work when spaces are in the URL.

Contributed by Deepa Remesh

 Attaching a patch 'derby-618-v2.diff' which includes code change and a test for this issue.
Patch does the following:

* Modifies ClientDriver.java - removes the space separator in the call to nextToken in tokenizeDatabase
method. This allows use of URL containing database name with spaces.

* Adds tests to jdbcapi/checkDriver.java for an url with spaces in database name. Since embedded
and jcc driver work with spaces, I added this test for all three frameworks. Test verfies
that the specified database gets created.

* Modifies master files for the test

Ran derbyall with Sun JDK 1.4.2 on Windows XP. I also ran jdbcapi/checkDriver.java with j9
vms. 


Modified:
    db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/checkDriver.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDriver.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDriver.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/checkDriver.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_22/checkDriver.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDriver.java

Modified: db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/client/org/apache/derby/jdbc/ClientDriver.java?rev=382917&r1=382916&r2=382917&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 Fri Mar  3 11:51:46
2006
@@ -317,7 +317,8 @@
     private static String tokenizeDatabase(java.util.StringTokenizer urlTokenizer,
                                            String url) throws SqlException {
         try {
-            String databaseName = urlTokenizer.nextToken(" \t\n\r\f;");
+        	// DERBY-618 - database name can contain spaces in the path
+            String databaseName = urlTokenizer.nextToken("\t\n\r\f;");
             return databaseName;
         } catch (java.util.NoSuchElementException e) {
             // A null log writer is passed, because jdbc 1 sqlexceptions are automatically
traced

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/checkDriver.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/checkDriver.out?rev=382917&r1=382916&r2=382917&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/checkDriver.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/checkDriver.out
Fri Mar  3 11:51:46 2006
@@ -5,3 +5,10 @@
 checking acceptsURL(jdbc:derby://xxxFILTERED_HOSTNAMExxx:1527/wombat;create=true)
 checking acceptsURL(jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:1527/wombat;create=true)
 checking acceptsURL(jdbc:db2j:wombat;create=true)
+START testDbNameWithSpaces ...
+Connection info for connect(jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:1527/db name with spaces;create=true,
{user=tester, password=testpass})
+getURL() = jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:1527/db name with spaces;create=true
+getUserName() = tester
+CURRENT SCHEMA = TESTER
+PASSED:Connection Successful with url: jdbc:derby:net://xxxFILTERED_HOSTNAMExxx:1527/db name
with spaces;create=true
+testDbNameWithSpaces PASSED - Database created successfully

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDriver.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDriver.out?rev=382917&r1=382916&r2=382917&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDriver.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDriver.out
Fri Mar  3 11:51:46 2006
@@ -51,3 +51,10 @@
 getUserName() = APP
 CURRENT SCHEMA = APP
 PASSED:Connection Successful with url: jdbc:derby://xxxFILTERED_HOSTNAMExxx:1527/'wombat';create=true
+START testDbNameWithSpaces ...
+Connection info for connect(jdbc:derby://xxxFILTERED_HOSTNAMExxx:1527/db name with spaces;create=true,
null)
+getURL() = jdbc:derby://xxxFILTERED_HOSTNAMExxx:1527/db name with spaces;create=true
+getUserName() = APP
+CURRENT SCHEMA = APP
+PASSED:Connection Successful with url: jdbc:derby://xxxFILTERED_HOSTNAMExxx:1527/db name
with spaces;create=true
+testDbNameWithSpaces PASSED - Database created successfully

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDriver.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDriver.out?rev=382917&r1=382916&r2=382917&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDriver.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/checkDriver.out
Fri Mar  3 11:51:46 2006
@@ -31,3 +31,10 @@
 getUserName() = testuser
 CURRENT SCHEMA = TESTUSER
 Expected Exception:08006:Database 'testcreatedb1' shutdown.
+START testDbNameWithSpaces ...
+Connection info for connect(jdbc:derby:db name with spaces;create=true, null)
+getURL() = jdbc:derby:db name with spaces
+getUserName() = APP
+CURRENT SCHEMA = APP
+PASSED:Connection Successful with url: jdbc:derby:db name with spaces;create=true
+testDbNameWithSpaces PASSED - Database created successfully

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/checkDriver.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/checkDriver.out?rev=382917&r1=382916&r2=382917&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/checkDriver.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/checkDriver.out
Fri Mar  3 11:51:46 2006
@@ -31,3 +31,10 @@
 getUserName() = testuser
 CURRENT SCHEMA = TESTUSER
 Expected Exception:08006:Database 'testcreatedb1' shutdown.
+START testDbNameWithSpaces ...
+Connection info for connect(jdbc:derby:db name with spaces;create=true, null)
+getURL() = jdbc:derby:db name with spaces
+getUserName() = APP
+CURRENT SCHEMA = APP
+PASSED:Connection Successful with url: jdbc:derby:db name with spaces;create=true
+testDbNameWithSpaces PASSED - Database created successfully

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_22/checkDriver.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_22/checkDriver.out?rev=382917&r1=382916&r2=382917&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_22/checkDriver.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/j9_22/checkDriver.out
Fri Mar  3 11:51:46 2006
@@ -31,3 +31,10 @@
 getUserName() = testuser
 CURRENT SCHEMA = TESTUSER
 Expected Exception:08006:Database 'testcreatedb1' shutdown.
+START testDbNameWithSpaces ...
+Connection info for connect(jdbc:derby:db name with spaces;create=true, null)
+getURL() = jdbc:derby:db name with spaces
+getUserName() = APP
+CURRENT SCHEMA = APP
+PASSED:Connection Successful with url: jdbc:derby:db name with spaces;create=true
+testDbNameWithSpaces PASSED - Database created successfully

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDriver.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDriver.java?rev=382917&r1=382916&r2=382917&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDriver.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDriver.java
Fri Mar  3 11:51:46 2006
@@ -57,6 +57,13 @@
 	private static String CLIENT_URL_WITH_SINGLE_QUOTES1; 
 	private static String CLIENT_URL_WITH_SINGLE_QUOTES2;
 	
+	// DERBY-618 - Database name with spaces
+	private static String DB_NAME_WITH_SPACES = "db name with spaces";
+	private static String EMBEDDED_URL_WITH_SPACES = "jdbc:derby:" + 
+										DB_NAME_WITH_SPACES + ";create=true";
+	private static String CLIENT_URL_WITH_SPACES;
+	private static String JCC_URL_WITH_SPACES;
+	
 	/**
 	 * url prefix for this framework
 	 */
@@ -88,6 +95,9 @@
 		CLIENT_URL_WITH_DOUBLE_QUOTES2 = "jdbc:derby://" + hostName + ":1527/\"" + DERBY_SYSTEM_HOME
+ File.separator + "wombat\";create=true";
 		CLIENT_URL_WITH_SINGLE_QUOTES1 = "jdbc:derby://" + hostName + ":1527/'" + DERBY_SYSTEM_HOME
+ File.separator + "wombat';create=true";
 		CLIENT_URL_WITH_SINGLE_QUOTES2 = "jdbc:derby://" + hostName + ":1527/'wombat';create=true";
+		
+		CLIENT_URL_WITH_SPACES = "jdbc:derby://" + hostName + ":1527/" + DB_NAME_WITH_SPACES +
";create=true"; 
+		JCC_URL_WITH_SPACES = "jdbc:derby:net://" + hostName + ":1527/" + DB_NAME_WITH_SPACES +
";create=true";
 	}
 
 	// URLS to check.  New urls need to also be added to the acceptsUrl table
@@ -132,6 +142,7 @@
 			testEmbeddedAttributes(driver);
 			testClientAttributes(driver);
 			doClientURLTest(driver);
+			testDbNameWithSpaces(driver);
 		}
 		catch (SQLException se)
 		{
@@ -377,6 +388,53 @@
 			}
 		}
 	}	
+	
+	/**
+	 * Tests URL with spaces in database name to check create and connect works. 
+	 * (DERBY-618). Make sure that the specified database gets created. We need 
+	 * to check this because even without the patch for DERBY-618, no exception
+	 * gets thrown when we try to connect to a database name with spaces. 
+	 * Instead, client driver extracts the database name as the string before 
+	 * the first occurence of space separator. Hence the database which gets 
+	 * created is wrong. e.g, if we specified database name as 
+	 * "db name with spaces", the database that got created by client driver 
+	 * was "db", which was wrong. The URL returned by call to 
+	 * conn.getMetaData().getURL() was also wrong.      
+	 * 
+	 * @param driver
+	 * @throws SQLException
+	 */
+	private static void testDbNameWithSpaces(Driver driver) throws SQLException {
+		System.out.println("START testDbNameWithSpaces ...");
+		
+		Connection conn = null;
+		Properties info = null;
+		String url = null;
+		
+		if(TestUtil.isEmbeddedFramework())
+			url = EMBEDDED_URL_WITH_SPACES;
+		else if(TestUtil.isDerbyNetClientFramework()) 
+			url = CLIENT_URL_WITH_SPACES;
+		else if(TestUtil.isJCCFramework()) {
+			url = JCC_URL_WITH_SPACES;
+			// JCC requires user and password
+			info =  new Properties();
+			info.put("user", "tester");
+			info.put("password", "testpass");
+		}
+		
+		conn = testConnect(driver, url, info);
+		if(conn != null)
+			System.out.println("PASSED:Connection Successful with url: " + url );
+		
+		// Check that the specified database (with spaces) is created
+		File file = new File(DERBY_SYSTEM_HOME + File.separator + DB_NAME_WITH_SPACES);
+		if(file.exists())
+			System.out.println("testDbNameWithSpaces PASSED - Database created successfully");
+		else
+			System.out.println("testDbNameWithSpaces FAILED - Database not created correctly");
+		
+	}
 	
 	/**
 	 * Make  java.sql.Driver.connect(String url, Properties info call) and print the status
of



Mime
View raw message