Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package group_project;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.ResultSetMetaData;
- import java.sql.SQLException;
- import java.sql.Statement;
- public class Admin {
- public int ID, age, roomNum, balance;
- public String firstName, lastName, gender, identityCard, userName, password, roomType;
- public String checkInTime, checkOutTime, service, loggedIn;
- private static Connection conection;
- /* @author Jasmin Bektic
- *
- * Method confirms connection */
- public Connection getConnection() {
- try {
- String driver = "com.mysql.jdbc.Driver";
- String url = "jdbc:mysql://localhost:3306/hotel";
- String user = "root";
- String pass = "";
- Class.forName(driver);
- Connection con = DriverManager.getConnection(url, user, pass); //Connecting with provided url,userName and pass
- return con;
- } catch (Exception e) { //Catch errors
- System.out.println(e);
- }
- return null;
- }
- public void checkGuest() {
- }
- public void enterInfo() throws SQLException {
- Connection con = getConnection();
- String sql = "INSERT INTO information (information.FirstName,'lastName',Information.Gender,'identityCard','age','roomNum','roomType','checkInTime','userName','password') VALUES (?,?,?,?,?,?,?,?,?,?)";
- PreparedStatement statement = con.prepareStatement(sql);
- // statement.setString(1, s);
- // statement.setString(2, s);
- // statement.setString(3, s);
- statement.executeUpdate(sql);
- // ResultSet result = statement.executeQuery();
- // ResultSetMetaData rsmd = result.getMetaData();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement