Statement in Java

Getting a Statement from a Connection:
```
Statement stmt1 = conn.createStatement();
ResultSet rs =  stmt1.executeQuery("select * from species");
Statement stmt2 = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);
int result = stmt2.executeUpdate("insert into species values(10, 'Deer', 3)");
```
This signature of stmt2 takes two parameters. The first is the ResultSet type, and the other is the ResultSet concurrency mode. 
<b>ResultSet type options</b> 
ResultSet  Type | Can Go Backward | See Latest Data from Database Table | Supported by Most Drivers
------ | ------ | ------ | ------ 
ResultSet.TYPE_FORWARD_ONLY | No | No | Yes
ResultSet.TYPE_SCROLL_INSENSITIVE | Yes | No | Yes
ResultSet.TYPE_SCROLL_SENSITIVE | Yes | Yes | No

If the type you request isn’t available, the driver can “helpfully” downgrade to one that is.
<b>ResultSet concurrency mode options</b> 
ResultSet  Type | Can Read Data | Can Update Data | Supported by All Drivers
------ | ------ | ------ | ------ 
ResultSet.CONCUR_READ_ONLY | Yes | Yes | No
ResultSet.CONCUR_UPDATABLE | Yes | No | Yes

If the mode you request isn’t available, the driver can downgrade you.
<b>SQL runnable by execute method</b>
Method | DELETE | INSERT | SELECT | UPDATE
------ | ------ | ------ | ------ | ------ 
stmt.execute() | Yes | Yes | Yes | Yes
stmt.executeQuery() | No | No | Yes | No
stmt.executeUpdate() | Yes | Yes | No | Yes

<b>Return types of executes</b>
Method | Return Type | What Is Returned for SELECT | What Is Returned for DELETE/INSERT/UPDATE
------ | ------ | ------ | ------
stmt.execute() | boolean | true | false
stmt.executeQuery() | ResultSet | The rows and columns returned | n/a
stmt.executeUpdate() | int | n/a | Number of rows added/changed/removed

Also in real life, you should not use Statement directly. You should use a subclass called PreparedStatement. This subclass has three advantages: performance, security, and readability.