我想在java中动态地将双维数组插入ms-access ..
这是我的代码..
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Driver={Microsoft Access Driver " +
"(*.mdb, *.accdb)};DBQ=C:\\Documents and Settings\\ANIL KUMAR\\Desktop\\hyperdata.mdb";
con = DriverManager.getConnection(url);
System.out.println("Connected!");
}
catch (SQLException e) {
System.out.println("SQL Exception: "+ e.toString());
}
catch (Exception e) {
e.printStackTrace();
}
如果我有一个包含两列的字符串数组:
String[][] a = new String[10][2];
PreparedStatement pst = con.prepareStatement("INSERT INTO sap_details VALUES (?,?)");
for (int i = 0; i < 10; i++) {
pst.setString(1, a[i][0]);
pst.setString(2, a[i][1]);
pst.addBatch();
}
pst.executeBatch();
如果有一个包含 n 列和 n 行的字符串数组怎么办?如何插入字符串数组 a[n][n]?