Inserting large volumes of data into GBase 8s can be slow if you execute each row individually. The JDBC batch mechanism — with the IFX_USEPUT=1 parameter — slashes network round trips and boosts throughput dramatically in a gbase database.
Prerequisite
You must explicitly enable batch insert by adding IFX_USEPUT=1 to the JDBC URL. Without it, batching won't take effect.
Full Example
import java.sql.*;
public class Insert {
public static void main(String[] args) throws Exception {
String url = "jdbc:gbasedbt-sqli://192.168.50.150:9088/testdb:GBASEDBTSERVER=gbaseserver;IFX_USEPUT=1";
String username = "username";
String password = "password";
Class.forName("com.gbasedbt.jdbc.Driver");
Connection conn = DriverManager.getConnection(url, username, password);
PreparedStatement ps = conn.prepareStatement("INSERT INTO t1 VALUES (?)");
for (int i = 0; i < 10000; i++) {
ps.setString(1, "2024-10-16");
ps.addBatch();
}
ps.executeBatch();
ps.close();
conn.close();
}
}
How It Works
URL Configuration
AppendIFX_USEPUT=1to the connection string. This property is specific to GBASE's driver and instructs the driver to use the optimized bulk‑insert protocol.-
Batch Execution
-
addBatch()queues a parameter set without sending anything over the network. -
executeBatch()transmits all queued rows as a single block, so 10,000 inserts become just one round trip.
-
For even larger jobs, consider splitting input into chunks to keep transactions small and avoid excessive resource usage. This simple switch can turn a sluggish data load into a fast, efficient pipeline on your GBASE GBase 8s database.
Top comments (0)