Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select col1, col2, ... colN from table_name where col1 = ? ... ...
- 0 -> TABLE_1
- 1 -> TABLE_2
- 2 -> TABLE_3
- ...
- ...
- String usertypeCode = request.getParameter("usertype_code");
- String driver = ("com.mysql.jdbc.Driver");
- Class.forName(driver); // MySQL database connection
- Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/ebooking" + "?user=user&password=user");
- if (usertypeCode.equals("0") {
- usertype = "TABLE_0";
- } else if (usertypeCode.equals("1") {
- usertype = "TABLE_1";
- } else if (usertypeCode.equals("2") {
- usertype = "TABLE_2";
- } else {
- // handle invalid input
- }
- PreparedStatement pst = conn.prepareStatement("Select * from ? where stu_username=? and stu_password=?");
- pst.setString(1, usertype);
- pst.setString(2, username);
- pst.setString(3, password);
- ResultSet rs = pst.executeQuery();
- ...
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement