Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Login_Registration_Project;
- import java.sql.*;
- import java.util.*;
- /**
- * Created by Salek on 29.01.2017.
- */
- public class Login {
- public static void main (String[] args) {
- String url = "jdbc:mysql://localhost:3306/javabase";
- String user = "java";
- String passwd = "password";
- try {
- // 1. Get a connection to the DB
- Connection myConn = DriverManager.getConnection(url, user, passwd);
- // 2. Create a statement
- Statement myStmt = myConn.createStatement();
- // 3. Execute SQL query
- Scanner input = new Scanner (System.in);
- System.out.println("Please Login to the Clinic.");
- System.out.println("Login - Pesel: ");
- String Login = input.nextLine();
- System.out.println("Password: ");
- String Password = input.nextLine();
- String myQuery = "select * from shadow" +
- " where Password = '" + Password + "' and Pesel = '" + Login + "'";
- System.out.println(myQuery);
- ResultSet myRs = myStmt.executeQuery(myQuery);
- while (myRs.next()){
- System.out.println(myRs.getString("Password") + " " + myRs.getString("Pesel"));
- }
- if ()
- }
- catch (Exception exc) {
- exc.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement