Mercurial Hosting > luan
diff src/luan/modules/sql/Database.java @ 1268:725e52076f03
remove broken pooling
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 12 Nov 2018 03:54:04 -0700 |
parents | 9fa8b8389578 |
children | 25746915a241 |
line wrap: on
line diff
--- a/src/luan/modules/sql/Database.java Mon Nov 12 02:10:41 2018 -0700 +++ b/src/luan/modules/sql/Database.java Mon Nov 12 03:54:04 2018 -0700 @@ -1,6 +1,5 @@ package luan.modules.sql; -import java.io.Closeable; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; @@ -17,28 +16,9 @@ import luan.LuanException; -public final class Database implements Closeable { +public final class Database { private static final Logger logger = LoggerFactory.getLogger(Database.class); - private static Map<Map,Database> pool = new HashMap<Map,Database>(); - - public static Database get(Connection con) { - return new Database(con); - } - - public static synchronized Database get(LuanTable specTbl) - throws LuanException, ClassNotFoundException, SQLException - { - Map<Object,Object> spec = specTbl.asMap(); - Database db = pool.get(spec); - if( db==null ) { - db = new Database(spec); - pool.put(spec,db); - } - return db; - } - - public int uses = 0; public final Connection con; private final Map<String,PreparedStatement> pstmts = new HashMap<String,PreparedStatement>(); @@ -46,10 +26,10 @@ this.con = con; } - private Database(Map<Object,Object> spec) + public Database(LuanTable specTbl) throws LuanException, ClassNotFoundException, SQLException { - spec = new HashMap<Object,Object>(spec); + Map<Object,Object> spec = specTbl.asMap(); String cls = getString(spec,"class"); Class.forName(cls); String url = getString(spec,"url"); @@ -101,20 +81,4 @@ } } - public void close() { - try { - con.close(); - } catch(SQLException e) { - throw new RuntimeException(e); - } - } - - protected void finalize() throws Throwable { - if( !con.isClosed() ) { - logger.error("not closed"); - close(); - } - super.finalize(); - } - }