package jdbc;
import java.sql.*;
public class SQLServerJDBCDemo {
public static void main(String[] args) {
String driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url = "jdbc:microsoft:sqlserver://user046:1433;DatabaseName=pubs;User=sa;Password=";
Connection conn = null;
try {
Class.forName(driver);
conn = DriverManager.getConnection(url, "sa", "");
if (conn != null) {
System.out.println("JDBC Like Pub DataBase.");
System.out.println("conn.getCatalog() = " + conn.getCatalog());
}
}
catch (Exception ex) {
ex.printStackTrace();
}
try{
conn.close();
}catch(Exception ex){
ex.printStackTrace();
}
}
}