-2
大家好,有誰能告訴我這裏有什麼問題? 我有一個任務,我被問及我是新的連接oracle數據庫與java servlet。java.sql.sqlexception無效列索引
這裏是我的代碼:
try {
out.print("first");
Class.forName("oracle.jdbc.OracleDriver");
out.print("aaa");
Connection con
= DriverManager.getConnection(
"jdbc:oracle:thin:@localhost:1521:xe", "myusername", "mypassword");
out.print("111");
PreparedStatement ps = con
.prepareStatement(
"INSERT INTO signup
values(fn, ln, date, em, pa, crnum)
");
out.print("222");
ps.setString(1, fn);
ps.setString(2, ln);
ps.setString(3, da);
ps.setString(4, em);
ps.setString(5, pa);
ps.setString(6, cr);
int i = ps.executeUpdate();
if (i > 0) {
out.print("You are successfully registered...");
}
} catch (Exception e2) {
out.println(e2);
}
out.close();
response.sendRedirect("address");
/* when press next bottom
it'll take me to add.html*/
後,我跑了整個代碼我得到這個:java.sql.sqlexception: invalid column index
堆棧跟蹤指向哪一行? – assylias
*「INSERT INTO註冊值(fn,ln,date,em,pa,crnum)」* ...在編寫準備好的語句時使用instthsting樣式。我想沒有教程可以告訴你它是如何工作的,對嗎? – Tom