JDBC / CATATAN</>↗JDBC12 Feb 2026
To configure c3p0 as a JDBC connection pool, you typically: create a DataSource (usually ComboPooledDataSource) tune pool parameters (min/max pool size, idle time, timeouts, statement cache) use the DataSource everywhere instead of DriverManager.getConnection(…) close Connection/Statement/ResultSet normally (c3p0 returns connections to the pool on close()) Below are the common ways to do it. 1) Programmatic configuration […]
JDBC / CATATAN</>↗JDBC12 Feb 2026
To configure an Apache DBCP connection pool for “plain” JDBC, you typically create a pooled DataSource once at startup, then get connections from it (and always close them to return to the pool). Below are the two most common approaches. 1) Recommended (DBCP2): BasicDataSource (simplest) Create and configure the pool package org.kodejava.jdbc; import org.apache.commons.dbcp2.BasicDataSource; import […]
JDBC / CATATAN</>↗JDBC11 Feb 2026
To use connection pooling in plain JDBC with HikariCP, the main shift is: stop using DriverManager.getConnection(…) everywhere create one DataSource (the pool) at startup whenever you need a DB connection, call dataSource.getConnection() always close resources with try-with-resources (closing returns the connection to the pool, it does not kill the physical connection) 1) Create a pooled […]
JDBC / CATATAN</>↗JDBC20 Jan 2026
Savepoints in JDBC provide fine-grained control over transactions by allowing you to roll back to a specific point within a transaction rather than undoing everything. This is particularly useful for handling optional operations or partial failures. Key Steps to Use Savepoints Disable Auto-commit: Savepoints only work within a manual transaction. Set a Savepoint: Use connection.setSavepoint() […]
JDBC / CATATAN</>↗JDBC19 Jan 2026
Using transactions in JDBC is essential when you need to ensure that a group of SQL statements either all succeed or all fail together (maintaining Atomicity). By default, a JDBC Connection is in auto-commit mode, meaning every single SQL statement is treated as its own transaction and committed immediately. To manage transactions manually, follow these […]
JDBC / CATATAN</>↗JDBC19 Jan 2026
To set the fetch size for large queries in Java using JDBC, you use the setFetchSize(int rows) method on a Statement or PreparedStatement object. This gives the JDBC driver a hint as to the number of rows that should be fetched from the database when more rows are needed. This is particularly useful for large […]