Guest User

Untitled

a guest
Oct 3rd, 2018
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. import com.microsoft.sqlserver.jdbc.SQLServerDriver;
  2. import java.sql.*;
  3. import java.sql.DriverManager;
  4.  
  5. import java.sql.SQLException;
  6. /**
  7.  *
  8.  * @author kem
  9.  */
  10. public class JDBC_123 {
  11.  
  12.     /**
  13.      * @param args the command line arguments
  14.      */
  15.    
  16.  
  17.  
  18.    
  19.     public  static void main(String[] args) {
  20.         try
  21.         {
  22.         Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
  23.         DriverManager.registerDriver(new SQLServerDriver());
  24.         String url="jdbc:sqlserver://127.0.0.1:1433;databaseName=TTT;user=sa;password=sa";
  25.         Connection con=DriverManager.getConnection(url);
  26.         if(con!=null)
  27.                     System.out.println("Connection Successful!");
  28.         }
  29.         catch (Exception e)
  30.         {
  31.            System.out.println("Error Trace in getConnection() : " + e.getMessage());
  32.         }
  33.    
  34.     }
  35.  
  36. }
Add Comment
Please, Sign In to add comment