0
我想插入雙維數組到MS-訪問動態java中..插入雙維數組到MS-訪問動態java中
這裏是我的代碼..
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]?