You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by km...@apache.org on 2006/03/09 19:51:23 UTC
svn commit: r384581 - in /db/derby/code/branches/10.1/java:
client/org/apache/derby/jdbc/
testing/org/apache/derbyTesting/functionTests/master/
testing/org/apache/derbyTesting/functionTests/master/DerbyNet/
testing/org/apache/derbyTesting/functionTests...
Author: kmarsden
Date: Thu Mar 9 10:51:21 2006
New Revision: 384581
URL: http://svn.apache.org/viewcvs?rev=384581&view=rev
Log:
DERBY-618 Make the client driver connection URL work when spaces are in the URL.
port from trunk
Contributed by Deepa Remesh
Added:
db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/checkDriver.out (with props)
Modified:
db/derby/code/branches/10.1/java/client/org/apache/derby/jdbc/ClientDriver.java
db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/checkDriver.out
db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDriver.out
db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/checkDriver.out
db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDriver.java
Modified: db/derby/code/branches/10.1/java/client/org/apache/derby/jdbc/ClientDriver.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/client/org/apache/derby/jdbc/ClientDriver.java?rev=384581&r1=384580&r2=384581&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/client/org/apache/derby/jdbc/ClientDriver.java (original)
+++ db/derby/code/branches/10.1/java/client/org/apache/derby/jdbc/ClientDriver.java Thu Mar 9 10:51:21 2006
@@ -298,7 +298,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/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/checkDriver.out
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/checkDriver.out?rev=384581&r1=384580&r2=384581&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/checkDriver.out (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/checkDriver.out Thu Mar 9 10:51:21 2006
@@ -5,3 +5,10 @@
checking acceptsURL(jdbc:derby://localhost:1527/wombat;create=true)
checking acceptsURL(jdbc:derby:net://localhost:1527/wombat;create=true)
checking acceptsURL(jdbc:db2j:wombat;create=true)
+START testDbNameWithSpaces ...
+Connection info for connect(jdbc:derby:net://localhost:1527/db name with spaces;create=true, {user=tester, password=testpass})
+getURL() = jdbc:derby:net://localhost:1527/db name with spaces;create=true
+getUserName() = tester
+CURRENT SCHEMA = TESTER
+PASSED:Connection Successful with url: jdbc:derby:net://localhost:1527/db name with spaces;create=true
+testDbNameWithSpaces PASSED - Database created successfully
Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDriver.out
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDriver.out?rev=384581&r1=384580&r2=384581&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDriver.out (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/checkDriver.out Thu Mar 9 10:51:21 2006
@@ -51,3 +51,10 @@
getUserName() = APP
CURRENT SCHEMA = APP
PASSED:Connection Successful with url: jdbc:derby://localhost:1527/'wombat';create=true
+START testDbNameWithSpaces ...
+Connection info for connect(jdbc:derby://localhost:1527/db name with spaces;create=true, null)
+getURL() = jdbc:derby://localhost:1527/db name with spaces;create=true
+getUserName() = APP
+CURRENT SCHEMA = APP
+PASSED:Connection Successful with url: jdbc:derby://localhost:1527/db name with spaces;create=true
+testDbNameWithSpaces PASSED - Database created successfully
Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/checkDriver.out
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/checkDriver.out?rev=384581&r1=384580&r2=384581&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/checkDriver.out (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/checkDriver.out Thu Mar 9 10:51:21 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
Added: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/checkDriver.out
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/checkDriver.out?rev=384581&view=auto
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/checkDriver.out (added)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/checkDriver.out Thu Mar 9 10:51:21 2006
@@ -0,0 +1,40 @@
+jdbcCompliant() = true
+driver.getMajorVersion() = EXPECTED VERSION
+driver.getMinorVersion() = EXPECTED VERSION
+checking acceptsURL(jdbc:derby:wombat;create=true)
+checking acceptsURL(jdbc:derby://localhost:1527/wombat;create=true)
+checking acceptsURL(jdbc:derby:net://localhost:1527/wombat;create=true)
+checking acceptsURL(jdbc:db2j:wombat;create=true)
+testEmbeddedAttributes()
+Connection info for connect(jdbc:derby:testcreatedb1, {create=true})
+getURL() = jdbc:derby:testcreatedb1
+getUserName() = APP
+CURRENT SCHEMA = APP
+Connection info for connect(jdbc:derby:testcreatedb2;create=true, null)
+getURL() = jdbc:derby:testcreatedb2
+getUserName() = APP
+CURRENT SCHEMA = APP
+Connection info for connect(jdbc:derby:testpropdb, {password=xxxx, user=APP})
+getURL() = jdbc:derby:testpropdb
+getUserName() = APP
+CURRENT SCHEMA = APP
+Connection info for connect(jdbc:derby:testpropdb;user=testuser;password=testpass, null)
+getURL() = jdbc:derby:testpropdb
+getUserName() = testuser
+CURRENT SCHEMA = TESTUSER
+Connection info for connect(jdbc:derby:testpropdb;user=testusr, {password=testpass})
+getURL() = jdbc:derby:testpropdb
+getUserName() = testusr
+CURRENT SCHEMA = TESTUSR
+Connection info for connect(jdbc:derby:testpropdb;user=testuser;password=testpass, null)
+getURL() = jdbc:derby:testpropdb
+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
Propchange: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/master/j9_13/checkDriver.out
------------------------------------------------------------------------------
svn:eol-style = native
Modified: db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDriver.java
URL: http://svn.apache.org/viewcvs/db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDriver.java?rev=384581&r1=384580&r2=384581&view=diff
==============================================================================
--- db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDriver.java (original)
+++ db/derby/code/branches/10.1/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/checkDriver.java Thu Mar 9 10:51:21 2006
@@ -62,6 +62,15 @@
private static String CLIENT_URL_WITH_SINGLE_QUOTES2 =
"jdbc:derby://localhost:1527/'wombat';create=true";
+ // 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 =
+ "jdbc:derby://localhost:1527/" + DB_NAME_WITH_SPACES + ";create=true";
+ private static String JCC_URL_WITH_SPACES =
+ "jdbc:derby:net://localhost:1527/" + DB_NAME_WITH_SPACES + ";create=true";
+
// URLS to check. New urls need to also be added to the acceptsUrl table
private static String[] urls = new String[]
{
@@ -126,6 +135,7 @@
testEmbeddedAttributes(driver);
testClientAttributes(driver);
doClientURLTest(driver);
+ testDbNameWithSpaces(driver);
}
catch (SQLException se)
{
@@ -371,6 +381,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