public int addTypes(List<taobaoBean> babyList) {
String sql = "insert into type (typeid,url) values (?,?) ";
Connection conn = dbhelper.getConnection(driver,url,username,upwd);
int result = 0;
PreparedStatement stmt =null;
try {
stmt = conn.prepareStatement(sql);
for(int i=0;i<babyList.size();i++){
stmt.setInt(1, babyList.get(i).getTypeId());
stmt.setString(2, babyList.get(i).getUrl());
stmt.addBatch();
}
stmt.executeBatch();
} catch (Exception e) {
e.printStackTrace();
}finally{
if (stmt != null) {
try {
stmt.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
dbhelper.closeCon(conn);
}
return result;
}
1分钟才插入3000条数据,如何变快。