# Execute SQL Statements Using Java
__*Execute SQL statements using Java*__
+ **`createStatement()`**: Creates a **`Statement`** object from a **`Connection`** object:
+ The Statement object supports the following method:
    + **`executeUpdate()`**: modify the status of the database
        + Returns an integer representing the number of rows affected by the `SQL` statement
        + Does not return a result set
    + **`executeQuery()`**: for queries
        + The result set is return as a **`ResultSet`** object
```
import java.sql.Statement;
...
Statement statement;
statement = conn.~!@createStatement()@!~;
```

------------------------------------------------------------
To execute SQL on the TiDB server using the Java API, you must first create a Statement object by calling the Connection object's createStatement() method and storing the returned Statement object.

The Java API requires you to use a different method on the Statement object to execute the SQL depending on whether you intend to modify the contents of the database or retrieve information from the database.

executeUpdate(): When you execute statements such as DML statements like INSERT, DELETE, UPDATE, and DDL statements like DROP TABLE, CREATE TABLE, the return value of executeUpdate() is the number of rows affected.

executeQuery(): When you execute statements such as SELECT, SHOW, EXPLAIN, or DESCRIBE, the return value of executeQuery() is an object of type ResultSet.

SQL statement terminators (; or \g.) are not required when coding with Connectors. The statement terminates at the end of the string it is defined in.
