main
黄海 2 years ago
parent 29cef3405b
commit 90fef4d855

@ -27,8 +27,7 @@ public class OpenGaussWriteShiWu_JDBC {
// 获取JDBC执行语句对象 // 获取JDBC执行语句对象
stmt = conn.createStatement(); stmt = conn.createStatement();
// 批量插入数据的SQL语句 // 批量插入数据的SQL语句
String sql = "INSERT INTO test(id, txt) " + String sql = "INSERT INTO test(id, txt) VALUES (?, ?)";
"VALUES (?, ?)";
// 预编译SQL语句并添加批量操作数据 // 预编译SQL语句并添加批量操作数据
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();

@ -62,7 +62,6 @@ public class OpenGaussWriteShiWu_Jfinal {
Connection conn = null; Connection conn = null;
try { try {
conn = DbKit.getConfig().getDataSource().getConnection(); conn = DbKit.getConfig().getDataSource().getConnection();
DbKit.getConfig().setThreadLocalConnection(conn);
conn.setAutoCommit(false); conn.setAutoCommit(false);
String sql = "INSERT INTO test(id, txt) " + "VALUES (?, ?)"; String sql = "INSERT INTO test(id, txt) " + "VALUES (?, ?)";
PreparedStatement pstmt = conn.prepareStatement(sql); PreparedStatement pstmt = conn.prepareStatement(sql);
@ -87,7 +86,6 @@ public class OpenGaussWriteShiWu_Jfinal {
if (null != conn) { if (null != conn) {
conn.close(); conn.close();
} }
DbKit.getConfig().removeThreadLocalConnection();
} }
long end = System.currentTimeMillis(); long end = System.currentTimeMillis();
long elapsed = end - start; long elapsed = end - start;

Loading…
Cancel
Save