Advertisement
Guest User

Untitled

a guest
Jul 20th, 2016
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. package sk.status.florko.db;
  2.  
  3. import org.hsqldb.jdbc.JDBCDataSource;
  4.  
  5. public class DataSourceFactory
  6. {
  7.  
  8. private static final DataSourceFactory INSTANCE = new DataSourceFactory();
  9. private static final String URL = "jdbc:hsqldb:hsql://localhost/StatusWebDB";
  10. private static final String USERNAME = "SA";
  11. private static final String PASSWORD = "";
  12. private JDBCDataSource dataSource;
  13.  
  14. public DataSourceFactory()
  15. {
  16.  
  17. }
  18.  
  19. public static DataSourceFactory getInstance()
  20. {
  21. return INSTANCE;
  22. }
  23.  
  24. public JDBCDataSource getDataSource()
  25. {
  26. if (dataSource == null)
  27. {
  28. dataSource = new JDBCDataSource();
  29. dataSource.setURL(URL);
  30. dataSource.setUser(USERNAME);
  31. dataSource.setPassword(PASSWORD);
  32. }
  33. return dataSource;
  34. }
  35.  
  36. public JDBCDataSource getDataSourceForTesting()
  37. {
  38. //ak by sme mali specialnu databazu na testovanie tak tu pridat vytvorenie datasource
  39. return getDataSource();
  40. }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement