Patch to fix the following minor bugs in dblook tool:
-  generates error when correct connection url is specified as
"jdbc:derby:test"

-  generates error when correct connection url is in single quotes as
'jdbc:derby:test'

-  usage text specifies Cloudscape
-  error message specifies cslook
-  erroneous command line arguments do not generate expected error, e.g.
          java org.apache.derby.tools.dblook -d 'jdbc:derby:test'
-oqwerty a.log
          generates ddl on the console instead of displaying usage text

Index: java/tools/org/apache/derby/tools/dblook.java
===================================================================
--- java/tools/org/apache/derby/tools/dblook.java       (revision 46313)
+++ java/tools/org/apache/derby/tools/dblook.java       (working copy)
@@ -231,16 +231,20 @@
                        case 'd':
                                if (!haveVal)
                                        return -1;
-                               if (args[start].length() == 2)
-                                       sourceDBUrl = args[++start];
-                               return start;
+                               if (args[start].length() == 2) {
+                                       sourceDBUrl = 
stripQuotes(args[++start]);
+                                       return start;
+                               }
+                               return -1;
 
                        case 'z':
                                if (!haveVal)
                                        return -1;
-                               if (args[start].length() == 2)
+                               if (args[start].length() == 2) {
                                        schemaParam = args[++start];
-                               return start;
+                                       return start;
+                               }
+                               return -1;
 
                        case 't':
                                if (!haveVal)
@@ -256,9 +260,11 @@
                        case 'o':
                                if (!haveVal)
                                        return -1;
-                               if ((args[start].length() == 2) && 
(args[start+1].length() > 0))
+                               if ((args[start].length() == 2) && 
(args[start+1].length() > 0)){
                                        ddlFileName = args[++start];
-                               return start;
+                                       return start;
+                               }
+                               return -1;
 
                        case 'a':
                                if (args[start].equals("-append")) {
@@ -342,9 +348,9 @@
                start = dbUrl.indexOf("net://");
                if (start == -1)
                // standard url (jdbc:derby:<dbname>).  Database
-               // name starts right after "cloudscape:".  The "11" in
-               // the following line is the length of "cloudscape:".
-                       start = dbUrl.indexOf("cloudscape:") + 11;
+               // name starts right after "derby:".  The "6" in
+               // the following line is the length of "derby:".
+                       start = dbUrl.indexOf("derby:") + 6;
                else
                // Network Server url.  Database name starts right
                // after next slash (":net://hostname:port/<dbname>).
Index: java/tools/org/apache/derby/loc/toolsmessages.properties
===================================================================
--- java/tools/org/apache/derby/loc/toolsmessages.properties    (revision 46313)
+++ java/tools/org/apache/derby/loc/toolsmessages.properties    (working copy)
@@ -181,7 +181,7 @@
 \ USAGE:\n\ java org.apache.derby.tools.dblook -d <sourceDBUrl> [OPTIONS]\n\n\
 \ \twhere the source URL is the full URL, including the connection protocol\n\
 \ \tand any connection attributes that might apply.  For example, use\n\
-\ \t'jdbc:cloudscape:myDB', or 
'jdbc:cloudscape:net://localhost:1527/myDB:user=usr;'. \n\n\
+\ \t'jdbc:derby:myDB', or 'jdbc:derby:net://localhost:1527/myDB:user=usr;'. 
\n\n\
 \ \toptions include: \n\n\
 \ \t-z <schemaName> to specify a schema to which the DDL generation\n\
 \ \t should be limited.  Only database objects with that schema will have\n\
@@ -199,19 +199,19 @@
 \ \t will be written.\n\
 \ \t\tIf not specified, default is the console.\
 \ \n
-CSLOOK_FileCreation=This file was created using Cloudscape's cslook utility.
+CSLOOK_FileCreation=This file was created using Derby's dblook utility.
 CSLOOK_OutputLocation=Output will be sent to file {0}\n
 CSLOOK_Timestamp=Timestamp: {0}
 CSLOOK_DBName=Source database is: {0}
 CSLOOK_DBUrl=Connection URL is: {0}
-CSLOOK_TargetTables=The cslook utility will consider only specified tables.
+CSLOOK_TargetTables=The dblook utility will consider only specified tables.
 CSLOOK_TargetSchema=Specified schema is: {0}
 # Directory com/ibm/db2j/tools/cslookImpl/...
 CSLOOK_Header=DDL Statements for {0}
 CSLOOK_Jar_Note=\
 **** NOTE **** In order for jar files to be loaded correctly,\n\
 -- you must either 1) ensure that the CSJARS directory (created\n\
--- automatically by cslook) exists where it was created (i.e. at\n\
+-- automatically by dblook) exists where it was created (i.e. at\n\
 -- the path shown in the statements below), or else 2) change the\n\
 -- path in the statements below to reflect the current location of\n\
 -- CSJARS.  If the CSJARS directory does not exist, or if it\n\
@@ -222,6 +222,6 @@
 CSLOOK_DefaultSchema=Reverting back to default schema 'APP'
 CSLOOK_AtLeastOneDebug=\
 -- Note: At least one unexpected error/warning message was\n\
--- encountered during DDL generation.  See cslook.log\n\
+-- encountered during DDL generation.  See dblook.log\n\
 -- to review the message(s).\n\
 \n

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to