Help Center/ MapReduce Service/ Developer Guide (LTS)/ Doris Development Guide (Security Mode)/ Doris Application Development/ Doris JDBC API Invoking Sample Program/ Inserting Data into a Doris Table
Updated on 2026-06-29 GMT+08:00
Inserting Data into a Doris Table
This section describes the sample code for inserting data into a Doris table.
The following code snippet is in the JDBCExample class.
Run the following SQL statement in Java JDBC mode to insert data into the dbName.tableName table of the cluster.
String insertTableSql = "insert into " + dbName + "." + tableName + " values(?, ?, ?)";
private static void insert(Connection connection, String sql) throws Exception {
int INSERT_BATCH_SIZE = 10;
try(PreparedStatement stmt = connection.prepareStatement(sql)) {
for (int i =0; i < INSERT_BATCH_SIZE; i++) {
stmt.setInt(1, i);
stmt.setInt(2, i * 10);
stmt.setString(3, String.valueOf(i * 100));
stmt.addBatch();
}
stmt.executeBatch();
} catch (Exception e) {
logger.error("Execute sql {} failed.", sql, e);
throw new Exception(e);
}
} Parent topic: Doris JDBC API Invoking Sample Program
What is your overall rating for this page?
0
1
2
3
4
5
6
7
8
9
10
Very dissatisfiedVery satisfied
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
The system is busy. Please try again later.
For any further questions, feel free to contact us through the chatbot.
Chatbot