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); } }
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); } }