Last active
August 29, 2015 14:01
-
-
Save gilfernandes/c5ee07737f274e294100 to your computer and use it in GitHub Desktop.
How to use connection pools
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static ResultSet executeSingleQuery(String query) throws ConnectorException { | |
Connection conn = null; | |
ResultSet data = null; | |
PreparedStatement stmt = null; | |
try { | |
conn = ConnectionFactory.LARGE.getConnection(dbDriver, dbUrl, dbUserName, dbPassword); | |
log.log(Level.INFO, "Query: {0}", query); | |
data = conn.prepareStatement(query).executeQuery(); | |
} catch (final SQLException sqle) { | |
log.log(Level.INFO, "Error SQLException: {0}", sqle.getMessage()); | |
throw new ConnectorException(sqle, null, null); | |
} finally { | |
ConnectionFactory.LARGE.close(stmt); | |
ConnectionFactory.LARGE.close(conn); | |
} | |
return data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment