Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. import java.sql.*;
  2.  
  3. class TestConnection
  4. {
  5. public static void main (String[] args)
  6. {
  7. try
  8. {
  9. // Step 1: Load the JDBC ODBC driver
  10. Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  11.  
  12. // Step 2: Establish the connection to the database
  13. String url = "jdbc:sqlserver://10.1.73.180\SQL2000;" +
  14. "databaseName=reportgen;user=sa;password=*****;";
  15. Connection conn = DriverManager.getConnection(url);
  16. System.out.println("Connected.");
  17. }
  18. catch (Exception e)
  19. {
  20. System.err.println("Got an exception! ");
  21. System.err.println(e.getMessage());
  22. }
  23. }
  24. }
  25.  
  26. Got an exception!
  27. com.microsoft.sqlserver.jdbc.SQLServerDriver
  28. Process exited with exit code 0.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement