hibernate3 中
Connection connetion = session
.connection()
connection
.setAutoCommit(false)
PreparedStatement ps = connection
.prepareStatement(
"sql")
long start = System
.currentTimeMillis()
for(Object bean : list){
ps
.setString(
1, MD5
.encryptionMD5(UUID
.randomUUID()
.toString()))
ps
.setString(
2, bean
.getCarCode())
ps
.setString(
3, bean
.getCardCode())
ps
.setString(
4, bean
.getInAddress())
ps
.setString(
5, bean
.getOutAddress())
ps
.setTimestamp(
6, new Timestamp(bean
.getInDate()
.getTime()))
ps
.setTimestamp(
7, new Timestamp(bean
.getOutDate()
.getTime()))
ps
.addBatch()
}
ps
.executeBatch()
connection
.commit()
long end = System
.currentTimeMillis()
System
.out.println(
"总共 " + list
.size() +
" 条数据,总耗时 : " + ((end-start)/
1000) +
" 秒")
hibernate4 中 通过doWork 来获取connect
转载请注明原文地址: https://ju.6miu.com/read-665678.html