Guest User

Untitled

a guest
Aug 12th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. properties file for JDBC
  2. javabase.jdbc.url = jdbc:mysql://200.230.71.12:3306/social
  3. javabase.jdbc.driver = com.mysql.jdbc.Driver
  4. javabase.jdbc.username = cepein
  5. javabase.jdbc.password = 1234cinco
  6.  
  7. # starting with file:
  8. shared.loader= /home/shaunkoo/NetBeansProjects/dao.properties
  9.  
  10. private static final String PROPERTIES_FILE = "/NetBeansProjects/dao.properties";
  11. private static final Properties PROPERTIES = new Properties();
  12.  
  13. static {
  14. ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
  15. InputStream propertiesFile = classLoader.getResourceAsStream(PROPERTIES_FILE);
  16.  
  17. # starting with file:
  18. shared.loader= /home/shaunkoo/NetBeansProjects/dao.properties
  19.  
  20. shared.loader= /home/shaunkoo/NetBeansProjects
  21.  
  22. private static final String PROPERTIES_FILE = "/NetBeansProjects/dao.properties";
  23.  
  24. private static final String PROPERTIES_FILE = "dao.properties";
  25.  
  26. public static DAOFactory getInstance(String name) throws DAOConfigurationException {
  27. if (name == null) {
  28. throw new DAOConfigurationException("Database name is null.");
  29. }
  30.  
  31. DAOProperties properties = new DAOProperties(name);
  32. String url = properties.getProperty(PROPERTY_URL, true);
  33.  
  34. Exception in thread "main" java.lang.ExceptionInInitializerError
  35. at mydao.DAOFactory.getInstance(DAOFactory.java:82)
  36. at mydao.DAOTest.main(DAOTest.java:45)
  37. Caused by: mydao.DAOConfigurationException: Properties file 'dao.properties' is missing in classpath.
  38. at mydao.DAOProperties.<clinit>(DAOProperties.java:28)
  39. ... 2 more
  40. enter code here
Add Comment
Please, Sign In to add comment