Connection conn = null;
PreparedStatement pst = null;
try {
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/chatdata", "admin", "int*M=9167757203");
pst = conn.prepareStatement("insert into user values (?, ?)");
} catch (Exception e) {
}
String password;
String userName;
try {
BufferedReader kin = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Username :: ");
userName = kin.readLine();
System.out.println("Enter Password :: ");
password = kin.readLine();
pst.setString(1, userName);
pst.setString(2, password);
pst.execute();
} catch (Exception e) {
System.out.println(e);
}
此代碼顯示我的錯誤匹配值計數:值java.sql.SQLException:列數並不在行1 JDBC
"java.sql.SQLException: Column count doesn't match value count at row 1"
雖然我的表有三列條目UID是AUTO_INCREMENT
和用戶名和密碼兩個字符串,我必須通過所以請如果有人可以找到答案請幫助。