Guest User

Untitled

a guest
Oct 30th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5.  
  6. package packageDonnes;
  7.  
  8. import java.sql.*;
  9. import oracle.jdbc.pool.OracleDataSource;
  10. import packageMetier.Films;
  11. /**
  12. *
  13. * @author Guillaume
  14. */
  15. public class Connexion {
  16.  
  17. public Connexion() {
  18. }
  19.  
  20. private Connection conn;
  21.  
  22. public Connection Connecter() throws java.sql.SQLException {
  23.  
  24. String userid = "p00000"; // A MODIFIER
  25. String password = "motmot"; // A MODIFIER
  26. String URL = "jdbc:oracle:thin:@iuta.univ-lyon1.fr:1521:orcl"; // Adresse de l'hote distant
  27. DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver() );
  28. conn = DriverManager.getConnection(URL,userid,password);
  29.  
  30. if( conn == null )
  31. {
  32. System.exit(1);
  33. }
  34. return(conn);
  35. }
  36.  
  37. public void closeConnection() throws java.sql.SQLException {
  38. conn.close(); // Fermeture de la connection
  39. }
  40. }
Add Comment
Please, Sign In to add comment