Advertisement
Guest User

Untitled

a guest
Jan 29th, 2017
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.42 KB | None | 0 0
  1. package Login_Registration_Project;
  2.  
  3.  
  4. import java.sql.*;
  5. import java.util.*;
  6.  
  7. /**
  8.  * Created by Salek on 29.01.2017.
  9.  */
  10. public class Login {
  11.     public static void main (String[] args) {
  12.  
  13.         String url = "jdbc:mysql://localhost:3306/javabase";
  14.         String user = "java";
  15.         String passwd = "password";
  16.  
  17.         try {
  18.             //  1. Get a connection to the DB
  19.             Connection myConn = DriverManager.getConnection(url, user, passwd);
  20.             //  2. Create a statement
  21.             Statement myStmt = myConn.createStatement();
  22.             //  3. Execute SQL query
  23.  
  24.             Scanner input = new Scanner (System.in);
  25.  
  26.             System.out.println("Please Login to the Clinic.");
  27.             System.out.println("Login - Pesel: ");
  28.             String Login = input.nextLine();
  29.             System.out.println("Password: ");
  30.             String Password = input.nextLine();
  31.  
  32.             String myQuery = "select * from shadow" +
  33.                     " where Password = '" + Password + "' and Pesel = '" + Login + "'";
  34.  
  35.  
  36.             System.out.println(myQuery);
  37.             ResultSet myRs = myStmt.executeQuery(myQuery);
  38.  
  39.             while (myRs.next()){
  40.                  System.out.println(myRs.getString("Password") + " " + myRs.getString("Pesel"));
  41.  
  42.             }
  43.  
  44.             if ()
  45.         }
  46.  
  47.  
  48.         catch (Exception exc) {
  49.         exc.printStackTrace();
  50.         }
  51.  
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement