This is a project to open jdbc as http service.
- run com.dbclient.jdbc.server.JdbcExecutorServer.main
- After execute, http-api will be exposed on port 7823.
The http service will provide the following Api.
Api | Desc |
---|---|
connect | Connect to database by jdbc url. |
alive | Check connection is alive. |
execute | Execute SQL by connection. |
cancel | Cancel executing statement. |
close | Close jdbc connection. |
POST http://127.0.0.1:7823/connect
Content-Type: application/json
{
"jdbcUrl": "jdbc:mysql://localhost:3306/test",
"driver": "com.mysql.cj.jdbc.Driver",
"driverPath": "D:/mysql-connector-java-8.0.29.jar",
"username": "root",
"password": "root",
"readonly": false,
"id": "mysql-connection"
}
Parameter: id: The id of the connection, specified by the user.
POST http://127.0.0.1:7823/connect
Content-Type: application/json
{
"id": "mysql-connection"
}
POST http://127.0.0.1:7823/execute
Content-Type: application/json
{
"id": "mysql-connection",
"sql": "select * from mysql.user",
"sqlList": ["select * from mysql.user","select * from mysql.user"]
}
Parameter:
- sql: The SQL you want to execute.
- sqlList: the SQL list you want to batch execute, When parameter sqlList is not empty, parameter sql will be ignored.
POST http://127.0.0.1:7823/cancel
Content-Type: application/json
{
"id": "mysql-connection"
}
POST http://127.0.0.1:7823/close
Content-Type: application/json
{
"id": "mysql-connection"
}
build: gradle fatJar