1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| private void initConnection() {
String driver = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
String userName = "user";
String passWord = "password";
String connectionUrl = "jdbc:sqlserver://SQLHRC00500P01:1433";
con = null;
try {
Class.forName(driver);
con = (Connection) DriverManager.getConnection(connectionUrl, userName, passWord);
} catch(ClassNotFoundException cnfe){
System.out.println("Driver not found");
cnfe.printStackTrace();
} catch (SQLException e) {
System.out.println("Sql Error");
System.out.println(e.getSQLState());
System.out.println(e.getStackTrace());
e.printStackTrace();
}
}
} |
Partager