Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package td7;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- /**
- *
- * @author usersio
- */
- public class DAOConnexion {
- // Attributs
- private static Connection connexion = null;
- private static final String URL = "jdbc:mysql://localhost:3306/home_v0";
- private static final String USER = "userapp";
- private static final String MDP = "pwapp";
- // Constructeur
- private DAOConnexion(){
- }
- // Getteur
- public static Connection getConnexion(){
- if (null==DAOConnexion.connexion){
- DAOConnexion.setConnexion();
- }
- return DAOConnexion.connexion;
- }
- // Setteur
- private static void setConnexion(){
- try {
- DAOConnexion.connexion = DriverManager.getConnection(DAOConnexion.URL, DAOConnexion.USER, DAOConnexion.MDP);
- }
- catch (SQLException e){
- System.out.println("td7.DAOConnexion.setConnexion()"+" : Problème de connexion à la bdd!");
- }
- }
- // Autres
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement