Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private String dbDriverName = "com.mysql.jdbc.Driver";
- private String dburl = "jdbc:mysql://localhost:3306/marfa_ghelasdb";
- private String dbuser = "ghelas_admin";
- private String dbpassword = "1234";
- private Connection connection;
- private static MyDataSource instance;
- public static MyDataSource getInstance() {
- if (instance == null) {
- instance = new MyDataSource();
- }
- return instance;
- }
- public Connection getConnection() throws SQLException {
- if (connection == null || (connection != null && connection.isClosed())) {
- connection = DriverManager.getConnection(dburl, dbuser, dbpassword);
- }
- return connection;
- }
- private void loadDriver() throws ClassNotFoundException {
- Class.forName(dbDriverName); //incarcarea jar-ului care corespunde numelui dat in JVM
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement