Changeset: 6082b52a4d46 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6082b52a4d46
Modified Files:
        java/src/nl/cwi/monetdb/util/PasswordField.java
Branch: jacqueline
Log Message:

Merged from default


diffs (truncated from 7282 to 300 lines):

diff --git a/java/ChangeLog.Apr2012 b/java/ChangeLog.Apr2012
--- a/java/ChangeLog.Apr2012
+++ b/java/ChangeLog.Apr2012
@@ -1,3 +1,7 @@
 # ChangeLog file for java
 # This file is updated with Maddlog
 
+* Fri Mar  2 2012 Wouter Alink <wou...@spinque.com>
+- Password reading by JdbcClient no longer results in strange artifacts
+- JdbcClient now returns exit code 1 in case of failures
+
diff --git a/java/Makefile.ag b/java/Makefile.ag
--- a/java/Makefile.ag
+++ b/java/Makefile.ag
@@ -27,7 +27,7 @@ JAVA_HOME = @JAVA_HOME@
 ant_distjdbc = {
        COND = HAVE_JAVAJDBC
        DIR = datadir/monetdb/lib
-       FILES = monetdb-mcl-1.7.jar monetdb-jdbc-2.2.jar jdbcclient.jar
+       FILES = monetdb-mcl-1.8.jar monetdb-jdbc-2.3.jar jdbcclient.jar
 }
 
 ant_distmerocontrol = {
diff --git a/java/build.properties b/java/build.properties
--- a/java/build.properties
+++ b/java/build.properties
@@ -9,7 +9,7 @@
 # major release number
 MCL_MAJOR=1
 # minor release number
-MCL_MINOR=7
+MCL_MINOR=8
 
 
 ##
@@ -19,7 +19,7 @@ MCL_MINOR=7
 # major release number
 JDBC_MAJOR=2
 # minor release number
-JDBC_MINOR=2
+JDBC_MINOR=3
 # an additional identifying string
 JDBC_VER_SUFFIX=Liberica
 # the default port to connect on, if no port given when using SQL
diff --git a/java/pom.xml b/java/pom.xml
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -6,7 +6,7 @@
        <modelVersion>4.0.0</modelVersion>
        <groupId>monetdb</groupId>
        <artifactId>monetdb-jdbc</artifactId>
-       <version>2.2</version>
+       <version>2.3</version>
        <name>monetdb-jdbc</name>
        <description>MonetDB JDBC driver</description>
        <repositories>
diff --git a/java/release.txt b/java/release.txt
--- a/java/release.txt
+++ b/java/release.txt
@@ -1,8 +1,8 @@
 RELEASE NOTES
-MonetDB JDBC driver version 2.2 (Liberica/MCL-1.7)
+MonetDB JDBC driver version 2.3 (Liberica/MCL-1.8)
 Fabian Groffen <fabian.grof...@cwi.nl>
 
-Release date: 2012-02-28
+Release date: 2012-03-02
 
 
 This JDBC driver is designed for use with MonetDB, a main-memory
diff --git a/java/src/nl/cwi/monetdb/client/JMonetDB.java 
b/java/src/nl/cwi/monetdb/client/JMonetDB.java
--- a/java/src/nl/cwi/monetdb/client/JMonetDB.java
+++ b/java/src/nl/cwi/monetdb/client/JMonetDB.java
@@ -67,7 +67,7 @@ public class JMonetDB {
                        copts.processArgs(args);
                } catch (OptionsException e) {
                        System.err.println("Error: " + e.getMessage());
-                       System.exit(-1);
+                       System.exit(1);
                }
 
                if (copts.getOption("help").isPresent()) {
@@ -92,14 +92,12 @@ copts.produceHelpMessage()
                // we need the password from the user, fetch it with a pseudo
                // password protector
                if (pass == null) {
-                       try {
-                               char[] tmp = 
PasswordField.getPassword(System.in, "passhrase: ");
-                               if (tmp != null) pass = String.valueOf(tmp);
-                       } catch (IOException ioe) {
+                       char[] tmp = System.console().readPassword("passphrase: 
");
+                       if (tmp == null) {
                                System.err.println("Invalid passphrase!");
-                               System.exit(-1);
+                               System.exit(1);
                        }
-                       System.out.println("");
+                       pass = String.valueOf(tmp);
                }
 
                // build the hostname
@@ -118,7 +116,7 @@ copts.produceHelpMessage()
 
                if (!copts.getOption("command").isPresent()) {
                        System.err.println("need a command to execute (-c)");
-                       System.exit(-1);
+                       System.exit(1);
                }
 
                Control ctl = null;
@@ -126,7 +124,7 @@ copts.produceHelpMessage()
                        ctl = new Control(host, port, pass);
                } catch (IllegalArgumentException e) {
                        System.err.println(e.getMessage());
-                       System.exit(-1);
+                       System.exit(1);
                }
                // FIXME: Control needs to respect Xhash
 
diff --git a/java/src/nl/cwi/monetdb/client/JdbcClient.java 
b/java/src/nl/cwi/monetdb/client/JdbcClient.java
--- a/java/src/nl/cwi/monetdb/client/JdbcClient.java
+++ b/java/src/nl/cwi/monetdb/client/JdbcClient.java
@@ -126,7 +126,7 @@ public class JdbcClient {
                                copts.processFile(pref);
                        } catch (OptionsException e) {
                                System.err.println("Error in " + 
pref.getAbsolutePath() + ": " + e.getMessage());
-                               System.exit(-1);
+                               System.exit(1);
                        }
                        user = copts.getOption("user").getArgument();
                        pass = copts.getOption("password").getArgument();
@@ -139,7 +139,7 @@ public class JdbcClient {
                        copts.processArgs(args);
                } catch (OptionsException e) {
                        System.err.println("Error: " + e.getMessage());
-                       System.exit(-1);
+                       System.exit(1);
                }
                // we can actually compare pointers (objects) here
                if (user != copts.getOption("user").getArgument()) pass = null;
@@ -189,14 +189,12 @@ copts.produceHelpMessage()
                // we need the password from the user, fetch it with a pseudo
                // password protector
                if (pass == null) {
-                       try {
-                               char[] tmp = 
PasswordField.getPassword(System.in, "password: ");
-                               if (tmp != null) pass = String.valueOf(tmp);
-                       } catch (IOException ioe) {
+                       char[] tmp = System.console().readPassword("password: 
");
+                       if (tmp == null) {
                                System.err.println("Invalid password!");
-                               System.exit(-1);
+                               System.exit(1);
                        }
-                       System.out.println("");
+                       pass = String.valueOf(tmp);
                }
 
                user = copts.getOption("user").getArgument();
@@ -253,7 +251,7 @@ copts.produceHelpMessage()
                        con.clearWarnings();
                } catch (SQLException e) {
                        System.err.println("Database connect failed: " + 
e.getMessage());
-                       System.exit(-1);
+                       System.exit(1);
                }
                try {
                        dbmd = con.getMetaData();
@@ -281,7 +279,7 @@ copts.produceHelpMessage()
                        // request the tables available in the database
                        tbl = dbmd.getTables(null, null, null, types);
 
-                       LinkedList tables = new LinkedList();
+                       List<Table> tables = new LinkedList<Table>();
                        while (tbl.next()) {
                                tables.add(new Table(
                                        tbl.getString("TABLE_CAT"),
@@ -341,14 +339,14 @@ copts.produceHelpMessage()
                                // search for cycles of type a -> (x ->)+ b 
probably not
                                // the most optimal way, but it works by just 
scanning
                                // every table for loops in a recursive manor
-                               for (int i = 0; i < tables.size(); i++) {
-                                       
Table.checkForLoop((Table)(tables.get(i)), new ArrayList());
+                               for (Table t : tables) {
+                                       Table.checkForLoop(t, new 
ArrayList<Table>());
                                }
 
                                // find the graph, at this point we know there 
are no
                                // cycles, thus a solution exists
                                for (int i = 0; i < tables.size(); i++) {
-                                       List needs = 
((Table)(tables.get(i))).requires(tables.subList(0, i + 1));
+                                       List<Table> needs = 
tables.get(i).requires(tables.subList(0, i + 1));
                                        if (needs.size() > 0) {
                                                tables.removeAll(needs);
                                                tables.addAll(i, needs);
@@ -360,9 +358,8 @@ copts.produceHelpMessage()
                                }
 
                                // we now have the right order to dump tables
-                               for (int i = 0; i < tables.size(); i++) {
+                               for (Table t : tables) {
                                        // dump the table
-                                       Table t = (Table)(tables.get(i));
                                        doDump(out, t, dbmd, stmt);
                                }
                        }
@@ -395,7 +392,7 @@ copts.produceHelpMessage()
                                        in = getReader(tmp);
                                } catch (Exception e) {
                                        System.err.println("Error: " + 
e.getMessage());
-                                       System.exit(-1);
+                                       System.exit(1);
                                }
 
                                // check for batch mode
@@ -448,7 +445,7 @@ copts.produceHelpMessage()
                        } catch (SQLException ex) {
                                // ok... nice try
                        }
-                       System.exit(-1);
+                       System.exit(1);
                }
        }
 
@@ -503,7 +500,7 @@ copts.produceHelpMessage()
                        throw new Exception("Invalid URL: " + e.getMessage());
                }
 
-               return(ret);
+               return ret;
        }
 
        /**
@@ -833,7 +830,7 @@ copts.produceHelpMessage()
 
        /**
         * Starts a processing loop optimized for processing (large) chunks of
-        * continous data, such as input from a file.  Unlike in the interactive
+        * continuous data, such as input from a file.  Unlike in the 
interactive
         * loop above, queries are sent only to the database if a certain batch
         * amount is reached.  No client side query checks are made, but 
everything
         * is sent to the server as-is.
@@ -843,7 +840,7 @@ copts.produceHelpMessage()
         * @throws IOException if an IO exception occurs.
         */
        public static void processBatch(int batchSize) throws IOException {
-               StringBuffer query = new StringBuffer();
+               StringBuilder query = new StringBuilder();
                String curLine;
                int i = 0;
                try {
@@ -917,8 +914,8 @@ copts.produceHelpMessage()
         * @return a prompt which consist of a username plus the top of the 
stack
         */
        private static String getPrompt(String user, SQLStack stack, boolean 
compl) {
-               return(user + (compl ? "-" : "=") +
-                       (stack.empty() ? ">" : "" + stack.peek()) + " ");
+               return user + (compl ? "-" : "=") +
+                       (stack.empty() ? ">" : "" + stack.peek()) + " ";
        }
 
        /**
@@ -1025,22 +1022,22 @@ copts.produceHelpMessage()
 
                if (start == stop) {
                        // we have an empty string
-                       return(new QueryPart(false, null, stack.peek() ==  '\'' 
|| stack.peek() == '"'));
+                       return new QueryPart(false, null, stack.peek() ==  '\'' 
|| stack.peek() == '"');
                } else if (stack.peek() ==  '\'' || stack.peek() == '"') {
                        // we have an open quote
-                       return(new QueryPart(false, query.substring(start, 
stop), true));
+                       return new QueryPart(false, query.substring(start, 
stop), true);
                } else {
                        // see if the string is complete
                        if (scolonterm && query.charAt(stop - 1) == ';') {
-                               return(new QueryPart(true, 
query.substring(start, stop), false));
+                               return new QueryPart(true, 
query.substring(start, stop), false);
                        } else {
-                               return(new QueryPart(false, 
query.substring(start, stop), false));
+                               return new QueryPart(false, 
query.substring(start, stop), false);
                        }
                }
        }
 
        public static String dq(String in) {
-               return("\"" + in.replaceAll("\\\\", 
"\\\\\\\\").replaceAll("\"", "\\\\\"") + "\"");
+               return "\"" + in.replaceAll("\\\\", 
"\\\\\\\\").replaceAll("\"", "\\\\\"") + "\"";
        }
 }
 
@@ -1061,19 +1058,19 @@ class QueryPart {
        }
 
        public boolean isEmpty() {
-               return(query == null);
+               return query == null;
        }
 
        public boolean isComplete() {
-               return(complete);
_______________________________________________
Checkin-list mailing list
Checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to