Mercurial Hosting > luan
diff src/luan/modules/sql/Database.java @ 1420:225808b90cee
options handling
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sat, 26 Oct 2019 22:21:09 -0600 |
parents | 27efb1fcbcb5 |
children |
line wrap: on
line diff
--- a/src/luan/modules/sql/Database.java Fri Oct 25 22:12:06 2019 -0600 +++ b/src/luan/modules/sql/Database.java Sat Oct 26 22:21:09 2019 -0600 @@ -28,26 +28,26 @@ this.con = con; } - public Database(LuanTable specTbl) + public Database(LuanTable spec) throws LuanException, ClassNotFoundException, SQLException { - Map<Object,Object> spec = specTbl.asMap(); + spec = new LuanTable(spec); String cls = Utils.removeRequiredString(spec,"class"); Class.forName(cls); String url = Utils.removeRequiredString(spec,"url"); Properties props = new Properties(); - props.putAll(spec); + props.putAll(spec.asMap()); this.con = DriverManager.getConnection(url,props); spec.remove("user"); spec.remove("password"); - set(spec); + set2(spec); } public void set(LuanTable options) throws LuanException, SQLException { - set(options.asMap()); + set2(new LuanTable(options)); } - private void set(Map<Object,Object> options) throws LuanException, SQLException { + private void set2(LuanTable options) throws LuanException, SQLException { Boolean autoCommit = Utils.removeBoolean(options,"auto_commit"); if( autoCommit != null ) con.setAutoCommit(autoCommit);