【发布时间】:2017-09-24 02:31:39
【问题描述】:
我在 java (eclipse) 中使用库 sqlite-jdbc-3.16.1.jar 建立了一个 sqlite 数据库。
table1 中有 5 行:id(ID Integer PRIMARY KEY AUTOINCREMENT), name, row3, row4, row5
我想插入名称、row3 和 row4 以及 id 以增加自身。
public static void insertTest(String name, byte[] contentRow3, byte[] contentRow4) {
String sql = "INSERT INTO table1(name, contentRow3, contentRow4) VALUES(?,?,?)";
try (Connection conn = connect();
PreparedStatement pstmt = conn.prepareStatement(sql)) {
pstmt.setString(2, name);
pstmt.setBytes(3, contentRow3);
pstmt.setBytes(4, contentRow4);
System.out.println("Added new Person to DB");
pstmt.executeUpdate();
} catch (SQLException e) {
System.out.println(e.getMessage());
}
}
错误:Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 3
这里有什么问题?
【问题讨论】:
标签: eclipse sqlite indexoutofboundsexception