Advertisement
Guest User

GUILLAUME

a guest
Sep 21st, 2016
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.65 KB | None | 0 0
  1. package fr.eni.dao;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6.  
  7. import com.microsoft.sqlserver.jdbc.SQLServerDriver;
  8.  
  9. public class AccesBdd
  10. {
  11.    
  12.     static
  13.     {
  14.         try {
  15.             DriverManager.registerDriver(new SQLServerDriver());
  16.         } catch (SQLException e) {
  17.             e.printStackTrace();
  18.         }
  19.     }
  20.    
  21.     public static Connection getConnection()
  22.     {
  23.         Connection cnx = null;
  24.         try
  25.         {
  26.             cnx = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databasename=TPJavaEE_GestionFormations;user=sa;password=Pa$$w0rd");
  27.         }
  28.         catch (SQLException e)
  29.         {
  30.             e.printStackTrace();
  31.         }
  32.         return cnx;
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement