Ejemplo n.º 1
0
 public Connection getConnection() {
   try {
     if (connection == null || connection.isClosed()) {
       loadJdbcDriver();
       connection =
           DriverManager.getConnection(
               GeneratorProperties.getRequiredProperty("jdbc.url"),
               GeneratorProperties.getRequiredProperty("jdbc.username"),
               GeneratorProperties.getProperty("jdbc.password"));
     }
     return connection;
   } catch (SQLException e) {
     throw new RuntimeException(e);
   }
 }
Ejemplo n.º 2
0
 private void loadJdbcDriver() {
   String driver = GeneratorProperties.getRequiredProperty("jdbc.driver");
   try {
     Class.forName(driver);
   } catch (ClassNotFoundException e) {
     throw new RuntimeException("not found jdbc driver class:[" + driver + "]", e);
   }
 }