Build an application by using a Druid connection pool, MySQL Connector/J, and seekdb
This topic describes how to build an application by using a Druid connection pool, MySQL Connector/J, and seekdb. The application implements basic database operations, including table creation, data insertion, data updating, data deletion, data query, and table deletion.
Download the druid-mysql-client sample project
Prerequisites
-
You have installed seekdb.
-
You have installed JDK 1.8 and Maven.
-
You have installed Eclipse.
infoThe tool used to run the code in this topic is Eclipse IDE for Java Developers 2022-03. You can also use other tools that you prefer.
Procedure
The following procedure describes how to compile and run the project in the Windows environment by using Eclipse IDE for Java Developers 2022-03. If you use other operating systems or compilers, the procedure may vary.
- Import the
druid-mysql-clientproject into Eclipse. - Obtain the seekdb URL.
- Modify the database connection information in the
druid-mysql-clientproject. - Run the
druid-mysql-clientproject.
Step 1: Import the druid-mysql-client project into Eclipse
-
Open Eclipse and choose File > Open Projects from File System.
-
In the dialog box that appears, click Directory to select the project directory and then click Finish.
infoWhen you import a Maven project into Eclipse, it automatically detects the
pom.xmlfile in the project, downloads the required dependency libraries based on the described dependencies in the file, and adds them to the project.
-
View the project.

Step 2: Obtain the seekdb URL
-
Contact the seekdb deployment personnel or administrator to obtain the corresponding database connection string.
Example:
mysql -hxxx.xxx.xxx.xxx -P2881 -uroot -p****** -DtestFor more information about the connection string, see Connect to seekdb by using a MySQL client.
-
Fill in the URL with the seekdb connection string information.
jdbc:mysql://$host:$port/$database_name?user=$user_name&password=$password&useSSL=falseParameter description:
$host: the IP address for connecting to seekdb. Replace it with the actual IP address. You can also use the local IP address or 127.0.0.1.$port: the port for connecting to seekdb. Replace it with the actual port. The default port is 2881, which can be customized when you deploy seekdb.$database_name: the name of the database to be accessed.user_name: the connection account. Format:username.password: the password for the account.
For more information about the MySQL Connector/J connection properties, see Configuration Properties.
Example:
jdbc:mysql://xxx.xxx.xxx.xxx:2881/test?user=root&password=******&useSSL=false