我的數據庫表沒有被插入這個信息,我看不到錯誤在哪裏,以及插入是否成功。請幫忙!MySQL數據庫表沒有被更新
try{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/payroll_system", "root", "");
PreparedStatement ps = con.prepareStatement("INSERT INTO payroll_system.employee_info(employeeID, FirstName, LastName, Admin,DOB,Address,Email,HourlyRate,Gender,ALeaveBalance,SLeaveBalance,ActiveStatus,Role,BSB,BankName,AccNumber,SuperNumber,SuperCompany) values(?,?,?,?,?,?,?,?,?,?,?,1,?,?,?,?,?,?)");
ps.setString(1, employee_id);
ps.setString(2, firstName);
ps.setString(3, lastName);
ps.setString(4, admin);
ps.setString(5, DOB);
ps.setString(6, address);
ps.setString(7, email);
ps.setString(8, HPR);
ps.setString(9, gender);
ps.setString(10, ALB);
ps.setString(11, SLB);
ps.setString(12, Role);
ps.setString(13, BSB);
ps.setString(14, BankName);
ps.setString(15, BAN);
ps.setString(16, SAC);
ps.setString(17, SAN);
ResultSet rs = ps.executeQuery();
st=rs.next();
if(st) {
out.println("Account successfully created!");
RequestDispatcher rd = request.getRequestDispatcher("index.html");
rd.include(request, response);
}
else{
RequestDispatcher rd = request.getRequestDispatcher("changePassAdmin.html");
rd.include(request, response);
}
}catch(Exception e)
{
e.printStackTrace();
}
out.close();
你得到任何異常?請發佈堆棧跟蹤 – WeMakeSoftware
@Funtik這是一個Web應用程序。當我按下html中的提交按鈕(對此servlet有表單操作)時,它只顯示一個帶有此servlet的url的空白頁面。 – javaprogrammer