Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static String login(){
- String Username = null;
- String Password = null;
- try {
- Class.forName("org.sqlite.JDBC");
- String dbURL = "jdbc:sqlite:/C:/Users/Alessandro/Desktop/db/HH_database.db";
- Connection conn = DriverManager.getConnection(dbURL);
- if (conn != null) {
- //GetUsername = JOptionPane.showInputDialog("Inserisci l'username");
- //GetPassword= JOptionPane.showInputDialog("Inserisci la password");
- Statement stmt = conn.createStatement();
- ResultSet rs;
- rs = stmt.executeQuery("SELECT Username, Password, Local_User_ID, Name, Surname FROM User_Data WHERE Username='" + Username + "' AND Password= '" + Password + "'");
- if(rs.next()){
- int id = rs.getInt("Local_User_ID");
- ArrayList<String> res = new ArrayList<String>();
- ArrayList<Integer> res_1 = new ArrayList<Integer>();
- ArrayList<String> res_2 = new ArrayList<String>();
- String nome = rs.getString("Name");
- String cognome = rs.getString("Surname");
- rs = stmt.executeQuery("SELECT Device_Description, D.Local_Device_ID, Feature_ID_List FROM User_Device_Map U, Devices D WHERE U.Local_Device_ID=D.Local_Device_ID AND Local_User_ID= '" + id + "'");
- while(rs.next()){
- String Device = rs.getString("Device_Description");
- String Features_ID_List = rs.getString("Feature_ID_List");
- int ID = rs.getInt("Local_Device_ID");
- res.add(Device);
- res_1.add(ID);
- res_2.add(Features_ID_List);
- }
- d = new InfoDevice(res_1, res, res_2, id);
- u = new UtenteCurrent(Username, Password, res, res_1);
- return InfoDevice.toJson(res, res_1, res_2);
- }
- conn.close();
- return "Username" + " " + Username + " " + "e" + " " + "Password" + " " + Password + " " + "Sbagliate";
- }
- } catch (ClassNotFoundException ex) {
- ex.printStackTrace();
- } catch (SQLException ex) {
- ex.printStackTrace();
- }
- return "ciao";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement