Wednesday, February 3, 2016



public class DBConnector {
 private static String url = null;
 private static String username = null;
 private static String password = null;
 private static String driver = null;
  Properties pp = new Properties();
  try {
   pp.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("")); // this one is better
  } catch (IOException e) {
   throw new RuntimeException(e);
  username = pp.getProperty("username");
  password = pp.getProperty("password");
  driver = pp.getProperty("driver");
  url = pp.getProperty("url");;
 //Other functions
For character encoding in properties file: use native2ascii from jdk/bin/, copy the String into native2ascii, it will translate to ascii

No comments:

Post a Comment