我有两个数组列表插入到数据库表的 2 列中,如下所示:
arraylist1: 123444, 324555, 6423643, 532326
arraylist2: jkfdsl, nkjfsdlj, jdslkfjdlkj, jfsldjfsk, fjdlskjfs
我编写了以下代码来插入数组列表,但它不起作用。我会感谢你的帮助。
try {
// Prepare a statement to insert a record
String sql = "INSERT INTO soundsdata.splog (arraylist1, arraylist2) VALUES(?,?)";
pstmt = (PreparedStatement) con.prepareStatement(sql);
pstmt.setArray(1,sptospring);
pstmt.setString(2,eachList.toString());
// Insert the row
pstmt.executeUpdate();
}finally {
pstmt.close();
}