# `SQLException`: Example

__*SQLException*__
__*SQLSTATE*__
__*ErrorCode*__

```12
private void doSomething() {
  try {
    ...
  }
  catch(SQLException e) {
    System.out.println("SQL Exception code:!" + e.~!@getErrorCode()@!~);
    System.out.println("SQL Exception state: " + e.~!@getSQLState()@!~);
    System.out.println("SQL Exception text: " + e.~!@getMessage()@!~);
  }
}
```

------------------------------------------------------------
`SQLSTATE` It is a SQL specification, and error codes are defined by MySQL and implement by TiDB.

Try modify the Java class pointed to by the following script to make it an error and observe the output.

Class demo scripts:

For macOS and Linux: https://github.com/pingcap/tidb-course-201-lab/blob/master/scripts/09-demo-jdbc-execute-update-tx-01-show.sh

For Windows: https://github.com/pingcap/tidb-course-201-lab/blob/master/scripts/09-demo-jdbc-execute-update-tx-01-show.bat