我有这个代码,我想将我的表存储ArrayList
在我的database
public class globaleCollab {
public static void main(String[] args) throws ClassNotFoundException {
long startTime = System.currentTimeMillis();
System.out.println(" les rating : ");
String idoperateur = "00000006092";//operateur cible njibh m session
sort1 sor = new sort1();
ArrayList<Integer> table = sor.tri();
String resultat_final = null;
for (int i = 0; i < table.size(); i++) {
resultat_final = resultat_final + "," + table.get(i).toString();
}
System.out.println(table);
System.out.println("-------" + resultat_final);
//insrt id user, resultat_final, temps d'exe, k ,
long stopTime = System.currentTimeMillis();
long elapsedTime = stopTime - startTime;
System.out.println("l temps est " + elapsedTime + "ms");
Connection con = null;
PreparedStatement ps;
ResultSet rs;
String query;
try {
Class.forName("com.mysql.jdbc.Driver");
con = DriverManager.getConnection("jdbc:mysql://localhost:3306/bd_recommandation", "root", "");
query = "insert into statistic (idoperateur,id) values(?,?)";
ps = con.prepareStatement(query);
ps.setString(1, idoperateur);
ps.setString(2, resultat_final);
//ps.setInt(3, k);
//ps.setLong(4, elapsedTime);
// ps.setString(2, resultat_final);
System.out.println("000000000000000000000000000");
ps.executeUpdate();
} catch (Exception e) {
}
}
但它没有用
如果您事先知道数组的最大大小,请参阅:JDBC 文档的这一页。但是,如果数组的大小未知,我建议创建一个新表,其中每一行都是一个索引,并且有一列保存整数。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句