Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
683 B
2
Indexable
Never
import java.sql.*;
import java.sql.DriverManager;

public class Connecter {
    Connection con;
    public Connecter() {

        try {
            Class.forName("com.mysql.cj.jdbc.Driver");
            System.out.println("connection ok");
        } catch (ClassNotFoundException e) {
            System.out.println("connection not ok");
            throw new RuntimeException(e);
        }
        try {
            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/gestion_stagiare", "root", "");
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
    }
    public Connection obtenirConnection(){return con;}
}
Leave a Comment