]> source.dussan.org Git - iciql.git/commitdiff
Fixed password bug in model generator tool (issue 7)
authorJames Moger <james.moger@gmail.com>
Tue, 18 Sep 2012 12:22:50 +0000 (08:22 -0400)
committerJames Moger <james.moger@gmail.com>
Tue, 18 Sep 2012 12:22:50 +0000 (08:22 -0400)
docs/05_releases.mkd
src/com/iciql/Db.java
src/com/iciql/util/GenerateModels.java

index c31a8b8d689a76ea0e176d10b1e1be3fed222358..fcaea77a1934061d4e2056a4c5dfe768773a0834 100644 (file)
@@ -4,6 +4,10 @@
 \r
 **%VERSION%** ([zip](http://code.google.com/p/iciql/downloads/detail?name=%ZIP%)|[jar](http://code.google.com/p/iciql/downloads/detail?name=%JAR%)) &nbsp; *released %BUILDDATE%*\r
 \r
+- Fixed password bug in model generator (issue 7)\r
+\r
+**1.1.0** &nbsp; *released 2012-08-20*\r
+\r
 - All bulk operations (insert all, update all, delete all) now use JDBC savepoints to ensure atomicity of the transaction\r
 \r
 **1.0.0** &nbsp; *released 2012-07-14*\r
index 6e23a5920107d934c27a0924c2f6be02aa72eb9a..d436b8ddf226a8b73d36883f0d2794974729ea16 100644 (file)
@@ -31,7 +31,6 @@ import java.util.HashMap;
 import java.util.HashSet;\r
 import java.util.List;\r
 import java.util.Map;\r
-import java.util.Properties;\r
 import java.util.Set;\r
 \r
 import javax.sql.DataSource;\r
@@ -158,6 +157,15 @@ public class Db {
                        throw new IciqlException(e);\r
                }\r
        }\r
+       \r
+       public static Db open(String url, String user, char[] password) {\r
+               try {\r
+                       Connection conn = JdbcUtils.getConnection(null, url, user, password == null ? null : new String(password));\r
+                       return new Db(conn);\r
+               } catch (SQLException e) {\r
+                       throw new IciqlException(e);\r
+               }\r
+       }\r
 \r
        /**\r
         * Create a new database instance using a data source. This method is fast,\r
@@ -179,17 +187,7 @@ public class Db {
                return new Db(conn);\r
        }\r
 \r
-       public static Db open(String url, String user, char[] password) {\r
-               try {\r
-                       Properties prop = new Properties();\r
-                       prop.setProperty("user", user);\r
-                       prop.put("password", password);\r
-                       Connection conn = JdbcUtils.getConnection(null, url, prop);\r
-                       return new Db(conn);\r
-               } catch (SQLException e) {\r
-                       throw new IciqlException(e);\r
-               }\r
-       }\r
+       \r
        \r
        /**\r
         * Convenience function to avoid import statements in application code.\r
index 1a6270f05aa42cc2f5c9eae69e5d220b1b9b2c63..eac9f6cc0ecef1d5eb822910121fc720c1749153 100644 (file)
@@ -24,8 +24,6 @@ import java.io.IOException;
 import java.io.PrintStream;
 import java.io.PrintWriter;
 import java.io.Writer;
-import java.sql.Connection;
-import java.sql.DriverManager;
 import java.sql.SQLException;
 import java.util.List;
 import java.util.regex.Matcher;
@@ -130,14 +128,12 @@ public class GenerateModels {
        public static void execute(String url, String user, String password, String schema, String table,
                        String packageName, String folder, boolean annotateSchema, boolean trimStrings)
                        throws SQLException {
-               Connection conn = null;
                try {
-                       conn = DriverManager.getConnection(url, user, password);
                        Db db;
                        if (password == null) {
                                db = Db.open(url, user, (String) null);
                        } else {
-                               db = Db.open(url, user, password.toCharArray());
+                               db = Db.open(url, user, password);
                        }
                        DbInspector inspector = new DbInspector(db);
                        List<String> models = inspector.generateModel(schema, table, packageName, annotateSchema,
@@ -164,8 +160,6 @@ public class GenerateModels {
                        }
                } catch (IOException io) {
                        throw new SQLException("could not generate model", io);
-               } finally {
-                       JdbcUtils.closeSilently(conn);
                }
        }