本文整理匯總了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;
}