提交 075899ac authored 作者: Thomas Mueller's avatar Thomas Mueller

--no commit message

--no commit message
上级 b6574a07
...@@ -44,7 +44,7 @@ public class Db { ...@@ -44,7 +44,7 @@ public class Db {
try { try {
this.conn = conn; this.conn = conn;
stat = conn.createStatement(); stat = conn.createStatement();
} catch (Exception e) { } catch (SQLException e) {
throw convert(e); throw convert(e);
} }
} }
...@@ -62,7 +62,7 @@ public class Db { ...@@ -62,7 +62,7 @@ public class Db {
try { try {
JdbcDriverUtils.load(url); JdbcDriverUtils.load(url);
return new Db(DriverManager.getConnection(url, user, password)); return new Db(DriverManager.getConnection(url, user, password));
} catch (Exception e) { } catch (SQLException e) {
throw convert(e); throw convert(e);
} }
} }
...@@ -81,7 +81,7 @@ public class Db { ...@@ -81,7 +81,7 @@ public class Db {
prepared.put(sql, prep); prepared.put(sql, prep);
} }
return new Prepared(conn.prepareStatement(sql)); return new Prepared(conn.prepareStatement(sql));
} catch (Exception e) { } catch (SQLException e) {
throw convert(e); throw convert(e);
} }
} }
...@@ -94,11 +94,17 @@ public class Db { ...@@ -94,11 +94,17 @@ public class Db {
public void execute(String sql) { public void execute(String sql) {
try { try {
stat.execute(sql); stat.execute(sql);
} catch (Exception e) { } catch (SQLException e) {
throw convert(e); throw convert(e);
} }
} }
/**
* Read a result set.
*
* @param rs the result set
* @return a list of maps
*/
static List query(ResultSet rs) throws SQLException { static List query(ResultSet rs) throws SQLException {
List list = new ArrayList(); List list = new ArrayList();
ResultSetMetaData meta = rs.getMetaData(); ResultSetMetaData meta = rs.getMetaData();
...@@ -122,7 +128,7 @@ public class Db { ...@@ -122,7 +128,7 @@ public class Db {
public List query(String sql) { public List query(String sql) {
try { try {
return query(stat.executeQuery(sql)); return query(stat.executeQuery(sql));
} catch (Exception e) { } catch (SQLException e) {
throw convert(e); throw convert(e);
} }
} }
...@@ -133,7 +139,7 @@ public class Db { ...@@ -133,7 +139,7 @@ public class Db {
public void close() { public void close() {
try { try {
conn.close(); conn.close();
} catch (Exception e) { } catch (SQLException e) {
throw convert(e); throw convert(e);
} }
} }
...@@ -158,7 +164,7 @@ public class Db { ...@@ -158,7 +164,7 @@ public class Db {
try { try {
prep.setInt(++index, x); prep.setInt(++index, x);
return this; return this;
} catch (Exception e) { } catch (SQLException e) {
throw convert(e); throw convert(e);
} }
} }
...@@ -172,7 +178,7 @@ public class Db { ...@@ -172,7 +178,7 @@ public class Db {
try { try {
prep.setString(++index, x); prep.setString(++index, x);
return this; return this;
} catch (Exception e) { } catch (SQLException e) {
throw convert(e); throw convert(e);
} }
} }
...@@ -186,7 +192,7 @@ public class Db { ...@@ -186,7 +192,7 @@ public class Db {
try { try {
prep.setBytes(++index, x); prep.setBytes(++index, x);
return this; return this;
} catch (Exception e) { } catch (SQLException e) {
throw convert(e); throw convert(e);
} }
} }
...@@ -200,7 +206,7 @@ public class Db { ...@@ -200,7 +206,7 @@ public class Db {
try { try {
prep.setBinaryStream(++index, x, -1); prep.setBinaryStream(++index, x, -1);
return this; return this;
} catch (Exception e) { } catch (SQLException e) {
throw convert(e); throw convert(e);
} }
} }
...@@ -211,7 +217,7 @@ public class Db { ...@@ -211,7 +217,7 @@ public class Db {
public void execute() { public void execute() {
try { try {
prep.execute(); prep.execute();
} catch (Exception e) { } catch (SQLException e) {
throw convert(e); throw convert(e);
} }
} }
...@@ -222,7 +228,7 @@ public class Db { ...@@ -222,7 +228,7 @@ public class Db {
public List query() { public List query() {
try { try {
return Db.query(prep.executeQuery()); return Db.query(prep.executeQuery());
} catch (Exception e) { } catch (SQLException e) {
throw convert(e); throw convert(e);
} }
} }
...@@ -241,7 +247,7 @@ public class Db { ...@@ -241,7 +247,7 @@ public class Db {
public void setAutoCommit(boolean autoCommit) { public void setAutoCommit(boolean autoCommit) {
try { try {
conn.setAutoCommit(autoCommit); conn.setAutoCommit(autoCommit);
} catch (Exception e) { } catch (SQLException e) {
throw convert(e); throw convert(e);
} }
} }
...@@ -252,7 +258,7 @@ public class Db { ...@@ -252,7 +258,7 @@ public class Db {
public void commit() { public void commit() {
try { try {
conn.commit(); conn.commit();
} catch (Exception e) { } catch (SQLException e) {
throw convert(e); throw convert(e);
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论