本文整理汇总了Java中java.sql.PreparedStatement.clearBatch方法的典型用法代码示例。如果您正苦于以下问题:Java PreparedStatement.clearBatch方法的具体用法?Java PreparedStatement.clearBatch怎么用?Java PreparedStatement.clearBatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.sql.PreparedStatement
的用法示例。
在下文中一共展示了PreparedStatement.clearBatch方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insert
import java.sql.PreparedStatement; //导入方法依赖的package包/类
private long insert(Connection con, List<Map<String, String>> list)
throws SQLException {
PreparedStatement ps;
String sql = "insert into travelrecord (id,user_id,traveldate,fee,days) values(?,?,?,?,?)";
ps = con.prepareStatement(sql);
for (Map<String, String> map : list) {
ps.setLong(1, Long.parseLong(map.get("id")));
ps.setString(2, (String) map.get("user_id"));
ps.setString(3, (String) map.get("traveldate"));
ps.setString(4, (String) map.get("fee"));
ps.setString(5, (String) map.get("days"));
ps.addBatch();
}
ps.executeBatch();
con.commit();
ps.clearBatch();
ps.close();
return list.size();
}
示例2: insert
import java.sql.PreparedStatement; //导入方法依赖的package包/类
private int insert(Connection con, List<Map<String, String>> list)
throws SQLException {
PreparedStatement ps;
String sql = "insert into travelrecord (user_id,traveldate,fee,days) values(?,?,?,?,?)";
ps = con.prepareStatement(sql);
for (Map<String, String> map : list) {
//ps.setLong(1, Long.parseLong(map.get("id")));
ps.setString(1, (String) map.get("user_id"));
ps.setString(2, (String) map.get("traveldate"));
ps.setString(3, (String) map.get("fee"));
ps.setString(4, (String) map.get("days"));
ps.addBatch();
}
ps.executeBatch();
con.commit();
ps.clearBatch();
ps.close();
return list.size();
}
示例3: insert
import java.sql.PreparedStatement; //导入方法依赖的package包/类
private long insert(Connection con, List<Map<String, String>> list)
throws SQLException {
PreparedStatement ps;
String sql = "insert into travelrecord (id,user_id,traveldate,fee,days) values(?,?,?,?,?)";
ps = con.prepareStatement(sql);
for (Map<String, String> map : list) {
ps.setLong(1, Long.parseLong(map.get("id")));
ps.setString(2, (String) map.get("user_id"));
ps.setString(3, (String) map.get("traveldate"));
ps.setString(4, (String) map.get("fee"));
ps.setString(5, (String) map.get("days"));
ps.addBatch();
}
ps.executeBatch();
con.commit();
ps.clearBatch();
ps.close();
return list.size();
}
示例4: insert
import java.sql.PreparedStatement; //导入方法依赖的package包/类
private int insert(Connection con, List<Map<String, String>> list)
throws SQLException {
PreparedStatement ps;
String sql = "insert into travelrecord (user_id,traveldate,fee,days) values(?,?,?,?,?)";
ps = con.prepareStatement(sql);
for (Map<String, String> map : list) {
//ps.setLong(1, Long.parseLong(map.get("id")));
ps.setString(1, (String) map.get("user_id"));
ps.setString(2, (String) map.get("traveldate"));
ps.setString(3, (String) map.get("fee"));
ps.setString(4, (String) map.get("days"));
ps.addBatch();
}
ps.executeBatch();
con.commit();
ps.clearBatch();
ps.close();
return list.size();
}
示例5: clearBatch
import java.sql.PreparedStatement; //导入方法依赖的package包/类
protected void clearBatch(PreparedStatement statement) {
try {
statement.clearBatch();
}
catch ( SQLException e ) {
LOG.unableToReleaseBatchStatement();
}
}
示例6: getPreparedStatement
import java.sql.PreparedStatement; //导入方法依赖的package包/类
/** Returns the PreparedStatement object for the input sql.
* @param sql the sql statement which needs to be precompiled.
* @throws SQLException if any database error occurs.
* @return the PreparedStatement object.
*/
public PreparedStatement getPreparedStatement(String sql) throws SQLException {
PreparedStatement pstmt = null;
// Use the regular prepared-statement if the logging is set to warn or higher, else use a proxy
if (log.getEffectiveLevel().isGreaterOrEqual(Level.WARN))
pstmt = m_connection.prepareStatement(sql);
else
pstmt = new PreparedStatementProxyForDebugging(m_connection, sql);
pstmt.clearBatch();
pstmt.clearParameters();
pstmt.clearWarnings();
registerStatement(pstmt, null);
return pstmt;
}