Skip to content

Latest commit

 

History

History
96 lines (70 loc) · 1.88 KB

README.md

File metadata and controls

96 lines (70 loc) · 1.88 KB

jdbc-adapter-server

This is a project to open jdbc as http service.

Develop

  1. run com.dbclient.jdbc.server.JdbcExecutorServer.main
  2. After execute, http-api will be exposed on port 7823.

Http-Api

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.

Request Example

connect

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.

alive

POST http://127.0.0.1:7823/connect
Content-Type: application/json

{
  "id": "mysql-connection"
}

execute

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.

cancel

POST http://127.0.0.1:7823/cancel
Content-Type: application/json

{
  "id": "mysql-connection"
}

close

POST http://127.0.0.1:7823/close
Content-Type: application/json

{
  "id": "mysql-connection"
}

build: gradle fatJar