OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

Product Overview
DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Connector/J

V2.4.18

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & CertificationTicket
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Connector/J
    3. V2.4.18
    iconOceanBase Connector/J
    V 2.4.18
    Databases
    • OceanBase Database
    • OceanBase Cloud
    • OceanBase Tugraph
    • Interactive Tutorials
    • OceanBase Best Practices
    Tools
    • OceanBase Cloud Platform
    • OceanBase Migration Service
    • OceanBase Developer Center
    • OceanBase Migration Assessment
    • OceanBase Admin Tool
    • OceanBase Loader and Dumper
    • OceanBase Deployer
    • Kubernetes operator for OceanBase
    • OceanBase Diagnostic Tool
    • OceanBase Binlog Service
    Connectors and Middleware
    • OceanBase Database Proxy
    • Embedded SQL in C for OceanBase
    • OceanBase Call Interface
    • OceanBase Connector/C
    • OceanBase Connector/J
    • OceanBase Connector/ODBC
    • OceanBase Connector/NET
    • V 2.4.18
    • V 2.4.17
    • V 2.4.16
    • V 2.4.15
    • V 2.4.14
    • V 2.4.5
    • V 2.4.4
    • V 2.4.3
    • V 2.4.2
    • V 2.4.1
    • V 2.4.0
    • V 2.2.11
    • V 2.2.10
    • V 2.2.7
    • V 2.2.6
    • V 2.2.3
    • V 2.2.0

    Manage tables and data

    Last Updated:2026-05-11 09:50:06  Updated
    Share
    What is on this page
    DML operations
    DDL operations

    folded

    Share

    OceanBase Connector/J allows you to modify database tables and data by using DML and DDL operations.

    DML operations

    To perform an INSERT or UPDATE operation, create a Statement or PreparedStatement object. You can use a PreparedStatement object to run a statement with a set of input parameters. The prepareStatement method of a Connection object can define a statement, bind variables to parameters, and return a PreparedStatement object with a statement definition.

    A PreparedStatement object uses setXXX methods to bind data to a statement to be sent to the database.

    Example: Use a PreparedStatement object to perform an INSERT operation that adds two rows of data to the customers table.

    PreparedStatement ps = null;
    try{
        ps = conn.prepareStatement ("insert into customers (customerID, name) values (?, ?)");
        ps.setInt (1, 150);                 // The first question mark (?) corresponds to customerID.
        ps.setString (2, "Adam");     // The second question mark (?) corresponds to name.
        ps.execute ();
        ps.setInt (1, 207);           
        ps.setString (2, "Alice");   
        ps.execute ();
    }
    
    finally{
         if(ps!=null)
         ps.close();
    }
    

    DDL operations

    To perform a DDL operation, create a Statement or PreparedStatement object.

    Example: Use a Statement object to create a table in the database.

    // Create the customers table and the customerID and name columns.
    
    String query;
    Statement st=null;
    query="create table customers " +
              "(customerID int, " +
              "name varchar(50))";
    st = conn.createStatement();
    st.executeUpdate(query);
    st.close();    // Close the statement.
    

    If a DDL operation needs to be performed again, a new DDL statement must be prepared.

    Example: Prepare a DDL statement before a DDL operation is performed again.

    PreparedStatement ps = null;
    PreparedStatement ts = null;
    ps = conn.prepareStatement ("insert into customers(customerID, name) values (?, ?)");   // The first question mark (?) corresponds to customerID. The second question mark (?) corresponds to name. 
    ps.setInt (1, 150);            // Add a new customer whose name is Adam and ID is 150. 
    ps.setString (2, "Adam");      
    ps.execute ();    
    ts = conn.prepareStatement("truncate table customers"); 
    ts.executeUpdate();
    ps.setInt (1, 207);            // Add a new customer whose name is Alice and ID is 207.
    ps.setString (2, "Alice");      
    ps.execute (); 
    ts.close();
    ts = conn.prepareStatement("truncate table customers"); 
    ts.executeUpdate();
    if(ps!=null)
         ps.close();     // Close the statement.
    

    Previous topic

    Close ResultSet and Statement objects
    Last

    Next topic

    Commit changes
    Next
    What is on this page
    DML operations
    DDL operations