Advertisement
Guest User

Untitled

a guest
Apr 20th, 2016
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package appemp;
  7.  
  8. import java.sql.*;
  9.  
  10. /**
  11. *
  12. * @author stud
  13. */
  14. public class AppEmp {
  15.  
  16. private Connection conn=null;
  17. private ResultSet rs=null;
  18.  
  19.  
  20. public boolean conectare_mySql(String IP, String dbName, String user, String password) {
  21.  
  22. try {
  23. Class.forName("com.mysql.jdbc.Driver");
  24. conn = DriverManager.getConnection("jdbc:mysql://"+IP+"/"+dbName+"?" + "user="+user+ "&password="+password);
  25. System.out.println("Connection succesfull");
  26. return true;
  27. } catch(Exception ex) {
  28. ex.printStackTrace();
  29. return false;
  30. }
  31. }
  32.  
  33. public static void main(String[] args) {
  34. AppEmp app=new AppEmp();
  35. app.conectare_mySql("10.10.16.30","employees","admin","admin");
  36.  
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement