Guest User

Untitled

a guest
May 29th, 2017
43
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.  
  7. package baitap;
  8. import java.sql.*;
  9. import java.util.logging.Level;
  10. import java.util.logging.Logger;
  11. /**
  12. *
  13. * @author Po
  14. */
  15. public class SQLConnection {
  16. String connectionUrl = "jdbc:sqlserver://localhost:1189;" +
  17. "databaseName=TestConnection;user=sa;password=1";
  18. Connection con = null;
  19. public Connection KetNoi ()
  20. {
  21. try {
  22. Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  23. con = DriverManager.getConnection(connectionUrl);
  24. if(con!= null)
  25. System.out.println("done");
  26. con.close();
  27. } catch (ClassNotFoundException ex) {
  28. Logger.getLogger(SQLConnection.class.getName()).log(Level.SEVERE, null, ex);
  29. } catch (SQLException ex) {
  30. System.out.println("aaa");
  31. }
  32. }
  33. }
Add Comment
Please, Sign In to add comment