Advertisement
Guest User

Untitled

a guest
Mar 28th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package app.bank.ConnectionFactory;
  7.  
  8. import java.sql.Connection;
  9. import java.sql.SQLException;
  10. import org.apache.derby.jdbc.ClientDataSource;
  11.  
  12.  
  13.  
  14.  
  15. /**
  16. *
  17. * @author zaba37
  18. */
  19. public class ConnectionFactory {
  20.  
  21. private static ConnectionFactory instance;
  22. private ClientDataSource ds;
  23.  
  24. private ConnectionFactory() {
  25. ds = new ClientDataSource();
  26. ds.setDatabaseName("bank");
  27. ds.setUser("app");
  28. ds.setPassword("app");
  29. ds.setPortNumber(1527);
  30. ds.setServerName("localhost");
  31. }
  32.  
  33. public static ConnectionFactory getInstance() {
  34. if (instance == null) {
  35. instance = new ConnectionFactory();
  36. }
  37. return instance;
  38. }
  39.  
  40. public static Connection getConnection() throws SQLException {
  41. return getInstance().ds.getConnection();
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement