Advertisement
Guest User

Untitled

a guest
May 17th, 2016
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. import java.sql.*;
  2.  
  3. public class ConnexionMySQL {
  4.  
  5. Connection mysql=null;
  6. boolean connecte=false;
  7. public ConnexionMySQL(String nomServeur, String nomBase, String nomLogin, String motDePasse) throws ClassNotFoundException, ErrorMdp{
  8. try {
  9. Class.forName("com.mysql.jdbc.Driver");
  10. mysql=DriverManager.getConnection("jdbc:mysql://"+nomServeur+":3306/"+nomBase,nomLogin,motDePasse);
  11. }
  12. catch (SQLException e){
  13. System.out.println("Msg :"+e.getMessage()+e.getErrorCode());
  14. if (e.getErrorCode()==1045){
  15. throw new ErrorMdp();
  16. }
  17. }
  18. }
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement