Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.microsoft.sqlserver.jdbc.SQLServerDriver;
- import java.sql.*;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- /**
- *
- * @author kem
- */
- public class JDBC_123 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- try
- {
- Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
- DriverManager.registerDriver(new SQLServerDriver());
- String url="jdbc:sqlserver://127.0.0.1:1433;databaseName=TTT;user=sa;password=sa";
- Connection con=DriverManager.getConnection(url);
- if(con!=null)
- System.out.println("Connection Successful!");
- }
- catch (Exception e)
- {
- System.out.println("Error Trace in getConnection() : " + e.getMessage());
- }
- }
- }
Add Comment
Please, Sign In to add comment