Guest User

Untitled

a guest
Feb 18th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. PreparedStatement psd = con.prepareStatement("Select job,username,password from login where job=? and username=? and password=?");
  2. psd.setString(1, selection);
  3. psd.setString(2, username);
  4. psd.setString(3, password);
  5.  
  6. public static Connection getConnection() throws Exception{
  7.  
  8. try{
  9. String driver="com.mysql.jdbc.Driver";
  10. String url="jdbc:mysql://ip_address/database_NAME";
  11. String username="username";
  12. String password="password";
  13. Class.forName(driver);
  14.  
  15. Connection conn=DriverManager.getConnection(url,username,password);
  16. JOptionPane.showMessageDialog(null,"Connection Established");
  17. return conn;
  18. }catch(Exception e)
  19. {
  20. JOptionPane.showMessageDialog(null,"Not Connected to InternetnPlease Try Again","Error", JOptionPane.ERROR_MESSAGE);
  21. }
  22.  
  23. return null;
  24. }//getConnection
Add Comment
Please, Sign In to add comment