# Exercise 1: Database Connectors: Connector/J

## Prerequisites
+ Your TiDB serverless cluster is up and running.
+ The Java SDK environment is already configured on the operating system.
+ [git](https://git-scm.com/) is already installed on the operating system.

## Section 1: Preparation
1. Clone example scripts repository to the practice node (e.g: Your local macOS, Linux or VM in the Cloud).
```
$ git clone https://github.com/pingcap/tidb-course-201-lab
```

2. Go to working directory: `tidb-course-201-lab/scripts`.
```
$ cd tidb-course-201-lab/scripts
```

## Section 2: Making connection to TiDB Serverless
1. Go through the sample code - [DemoJdbcConnectionServerless.java](https://github.com/pingcap/tidb-course-201-lab/blob/master/scripts/DemoJdbcConnectionServerless.java).
  
    Pay attention line 10 to 14, where the code composes the connection string.

2. Run demo script, and note the output.
```
$ ./09-demo-jdbc-connection-serverless-01-show.sh <host> <user_name> <password>
```
    E.g. ./09-demo-jdbc-connection-serverless-01-show.sh gateway01.ap-southeast-1.prod.aws.tidbcloud.com 3hB7dXAzvejd5sc.root f0rRmzNqljdueyJr