Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. package group_project;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.PreparedStatement;
  6. import java.sql.ResultSet;
  7. import java.sql.ResultSetMetaData;
  8. import java.sql.SQLException;
  9. import java.sql.Statement;
  10.  
  11. public class Admin {
  12. public int ID, age, roomNum, balance;
  13. public String firstName, lastName, gender, identityCard, userName, password, roomType;
  14. public String checkInTime, checkOutTime, service, loggedIn;
  15. private static Connection conection;
  16.  
  17.  
  18. /* @author Jasmin Bektic
  19. *
  20. * Method confirms connection */
  21. public Connection getConnection() {
  22. try {
  23. String driver = "com.mysql.jdbc.Driver";
  24. String url = "jdbc:mysql://localhost:3306/hotel";
  25. String user = "root";
  26. String pass = "";
  27. Class.forName(driver);
  28.  
  29. Connection con = DriverManager.getConnection(url, user, pass); //Connecting with provided url,userName and pass
  30. return con;
  31. } catch (Exception e) { //Catch errors
  32. System.out.println(e);
  33. }
  34. return null;
  35. }
  36.  
  37. public void checkGuest() {
  38.  
  39. }
  40.  
  41. public void enterInfo() throws SQLException {
  42. Connection con = getConnection();
  43. String sql = "INSERT INTO information (information.FirstName,'lastName',Information.Gender,'identityCard','age','roomNum','roomType','checkInTime','userName','password') VALUES (?,?,?,?,?,?,?,?,?,?)";
  44. PreparedStatement statement = con.prepareStatement(sql);
  45. // statement.setString(1, s);
  46. // statement.setString(2, s);
  47. // statement.setString(3, s);
  48. statement.executeUpdate(sql);
  49. // ResultSet result = statement.executeQuery();
  50. // ResultSetMetaData rsmd = result.getMetaData();
  51. }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement