Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void connect(String FileName, boolean exitOnFail)
- {
- try {
- this.loadCredentialsFromFile(FileName);
- this.conn = DriverManager.getConnection("jdbc:mysql://" + this.host + "/" + this.db + "?" + "user=" + this.user + "&password=" + this.passwd);
- this.stmt = this.conn.createStatement();
- }
- catch(SQLException ex)
- {
- // handle any errors
- Main.logging.warning("While connectiong to DB: " + System.getProperty("line.separator")
- + "\tSQLException: " + ex.getMessage() + System.getProperty("line.separator")
- + "\tSQLState: " + ex.getSQLState() + System.getProperty("line.separator")
- + "\tVendorError: " + ex.getErrorCode() + System.getProperty("line.separator")
- );
- if(exitOnFail)
- {
- Main.logging.error("Program must shut down due SQL error. (see details in warnings)");
- System.exit(1);
- }
- }
- catch(Exception ex)
- {
- Main.logging.warning("While connectiong to DB: " + System.getProperty("line.separator")
- + "\tException: " + ex.getMessage()
- );
- if(exitOnFail)
- {
- Main.logging.error("Program must shut down due SQL error. (see details in warnings)");
- System.exit(1);
- }
- }
- }
Add Comment
Please, Sign In to add comment