Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- import java.util.Scanner;
- public class takeInput
- {
- public static void main (String arg[])
- {
- String url = "jdbc:mysql://localhost:3306/demo";
- String user = "bihim";
- String pass = "shimu";
- //int count = 0;
- try
- {
- //Connection to database
- Connection myConn = DriverManager.getConnection(url,user,pass);
- //Create Statement
- Statement mySt = myConn.createStatement();
- //Execute sql query
- //String sql = "insert into emp" + "(userid, pass)" + "values (?,?)";
- //mySt.executeUpdate(sql);
- //mySt = myConn.prepareStatement("insert into emp" + "(userid, pass)" + "values('?' , '?')");
- //Setting the parameters
- Scanner scan = new Scanner(System.in);
- // String uzer = scan.nextLine();
- // String puss = scan.nextLine();
- // PreparedStatement pst = null;
- // pst = myConn.prepareStatement(sql);
- // pst.setString(1, uzer);
- // pst.setString(2, puss);
- // pst.execute();
- //System.out.println("Insert Completed");
- String takeInput = scan.nextLine();
- //String takePass = scan.nextLine();
- ResultSet myRs = mySt.executeQuery("select userid from emp where userid='"+takeInput+"'");
- while (myRs.next())
- {
- if (takeInput.equals(myRs.getString("userid")))
- {
- System.out.println("You did it fam");
- }
- }
- }
- catch (Exception exc)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement