A quick code preview showing working example of using one of the best-performing JDBC connection pools in Java.
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
-- snippet --
Connection conn = null; PreparedStatement p_stmt = null;
try {
conn = ConnectionManager.ds.getConnection();
p_stmt = conn.prepareStatement(
"INSERT INTO articles (text,url,content) VALUES (?,?,?)");
p_stmt.setBytes(1, (new String("jsdhgkdjshgkjdshkg")).
getBytes("UTF8") );
p_stmt.setString(2, "http://dsfsfsfdsfdsfda");
p_stmt.setBytes(3, (new String("aadada")).getBytes("UTF8") );
p_stmt.executeUpdate();
} catch(Exception e) {
LOG.debug("Failed to execute a JDBC task: ", e );
} finally {
try {
p_stmt.close();
conn.close();
} catch ( Exception ex) {
LOG.error ( "Failed to finalize JDBC task: ", ex );
}
}
-- snippet --