Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) throws SQLException {
- /* Get DB parameters from properties file */
- String dbUser = rb.getString("username");
- String dbPassword = rb.getString("password");
- String dbUrl = rb.getString("url");
- String driverClassName = rb.getString("driverClassName");
- /* Initialize the class with the given string name */
- Class.forName(driverClassName);
- logger.debug("Connecting to DB...");
- Main.dbConnection = DriverManager.getConnection(dbUrl, dbUser, dbPassword);
- if (null == Main.dbConnection) {
- logger.fatal("Unable to connect to DB");
- } else {
- logger.info("Connected to DB");
- Main.dbConnection.setAutoCommit(false);
- }
- try {
- /* Elaborate */
- storeprocedure();
- dbConnection.commit();
- try {
- dbConnection.close();
- } catch (SQLException e) {
- logger.fatal("Unable to close db connection" + e.getMessage());
- }
- } catch (Exception e) {
- dbConnection.rollback();
- e.printStackTrace();
- }
- }
Add Comment
Please, Sign In to add comment