Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- public class ConnectionSqlServer {
- private static Connection connection;
- // win + r : sqlservermanager12.msc pour récupérer l'instance de ssms
- private static String url = "jdbc:sqlserver://localhost\\SQLExpress;databasename=FestivalCannes;user=sa;password=sql2014;integratedsecurity=false";
- //integradedsecurity=true : permet de se logguer avec l'auth windows, et on ne précise ni user ni psw
- public static Connection getConnection() throws SQLException{
- if(connection == null){
- connection = DriverManager.getConnection(url);
- }
- return connection;
- }
- public static void Close() throws SQLException{
- if(connection != null){
- connection.close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement