package database;import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;/**
 * @author jerrychen
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class DBConnect {

public DBConnect(){

}

public static Connection getConnect() throws SQLException{
//String url = "jdbc:odbc:school";
String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=school;User=sa;Password=sa";
Connection con = null;
try {
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
con = DriverManager.getConnection(url);
} catch (ClassNotFoundException e) {
System.err.println(e.getMessage());
}
if(con == null){
throw new SQLException("didn't get connection!");
}
return con;
}}