I have developed a plugin that requires database connections. But I have found a lack of documentation. Anyone can explain to me why wrappers are used?
phishie
I have developed a plugin that requires database connections. But I have found a lack of documentation. Anyone can explain to me why wrappers are used?
phishie
Phishie,
You can effectively ignore the wrappers – they’‘re just used to provide profiling services and connection pool management. The DbConnectionManager class is what you’'ll want to use to get a database connection. Standard code might look like:
Connection con = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
con = DbConnectionManager.getConnection();
pstmt = DbConnectionManager.createPreparedStatement(SOME_STATEMENT);
rs = pstmt.executeQuery();
// do stuff
}
catch (SQLException e) {
Log.error(e);
}
finally {
DbConnectionManager.closeConnection(rs, pstmt, con);
}
-Matt