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 app.bank.ConnectionFactory;
- import java.sql.Connection;
- import java.sql.SQLException;
- import org.apache.derby.jdbc.ClientDataSource;
- /**
- *
- * @author zaba37
- */
- public class ConnectionFactory {
- private static ConnectionFactory instance;
- private ClientDataSource ds;
- private ConnectionFactory() {
- ds = new ClientDataSource();
- ds.setDatabaseName("bank");
- ds.setUser("app");
- ds.setPassword("app");
- ds.setPortNumber(1527);
- ds.setServerName("localhost");
- }
- public static ConnectionFactory getInstance() {
- if (instance == null) {
- instance = new ConnectionFactory();
- }
- return instance;
- }
- public static Connection getConnection() throws SQLException {
- return getInstance().ds.getConnection();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement