Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.sql.*;
  4. import com.microsoft.sqlserver.jdbc.*;
  5.  
  6. public class Main {
  7. public static void main(String[] args) {
  8. String connectionString = "jdbc:sqlserver://localhost:1433;"
  9. +"database=QMT;"
  10. +"user=superadmin;"
  11. +"password=myPassword.;";
  12.  
  13. // Declare the JDBC objects.
  14. Connection connection = null;
  15.  
  16. try {
  17. connection = DriverManager.getConnection(connectionString);
  18.  
  19. }
  20. catch (Exception e) {
  21. e.printStackTrace();
  22. }
  23. finally {
  24. if (connection != null) try { connection.close(); } catch(Exception e) {}
  25. }
  26. }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement