Calcite 获取jdbc连接流程
一、类调用
简介:calcite可以连接各数据源,做查询。可以收口查询权限,查询多引擎需求
二、 获取Connection发送的请求
请求介绍文档:https://calcite.apache.org/avatica/docs/json_reference.html#closeconnectionrequest
第一个请求:openConnection
Connection connection = DriverManager.getConnection(url, properties);
{"request":"openConnection","connectionId":"17810271-59a0-4ae1-a764-073be9048ebd","info":{"password":"自定义密码","appId":"651544823162880","user":"自定义账号"}}
{"response":"openConnection","rpcMetadata":{"response":"rpcMetadata","serverAddress":"tx-bj-aa:5888"}}
第二个请求:connectionSync
{"request":"connectionSync",
"connectionId":"17810271-59a0-4ae1-a764-073be9048ebd",
"connProps":{"connProps":"connPropsImpl","autoCommit":null,"readOnly":null,"transactionIsolation":null,"catalog":null,"schema":null,"dirty":true}
}
{"response":"connectionSync",
"connProps":{"connProps":"connPropsImpl","autoCommit":null,"readOnly":null,"transactionIsolation":null,"catalog":null,"schema":null,"dirty":false},
"rpcMetadata":{"response":"rpcMetadata","serverAddress":"tx-bj-服务器:5888"}
}
Statement pS = connection.createStatement();
{"request":"createStatement","connectionId":"17810271-59a0-4ae1-a764-073be9048ebd"}
{"response":"createStatement",
"connectionId":"56965299-f5ba-4424-bb6e-b57f1f703658",
"statementId":1473,
"rpcMetadata":{"response":"rpcMetadata","serverAddress":"tx-bj-服务器:5888"}
}
pS.executeQuery(sql);
{"request":"prepareAndExecute",
"connectionId":"17810271-59a0-4ae1-a764-073be9048ebd",
"statementId":1479,
"sql":"SELECT * FROM dw.dwd_表名 limit 10",
"maxRowsInFirstFrame":-1,
"maxRowCount":-1
}
{
"response": "executeResults",
"missingStatement": false,
"rpcMetadata": {
"response": "rpcMetadata",
"serverAddress": "tx-bj-服务器:5888"
},
"results": [{
"response": "resultSet",
"connectionId": "17810271-59a0-4ae1-a764-073be9048ebd",
"statementId": 1479,
"ownStatement": true,
"signature": {
"columns": [{
"ordinal": 0,
"autoIncrement": false,
"caseSensitive": false,
"searchable": true,
"currency": false,
"nullable": 2,
"signed": false,
"displaySize": 2147483647,
"label": "md5_log",
"columnName": "md5_log",
"schemaName": "",
"precision": 2147483647,
"scale": 0,
"tableName": "",
"catalogName": "",
"type": {
"type": "scalar",
"id": 12,
"name": "varchar",
"rep": "STRING"
},
"readOnly": true,
"writable": false,
"definitelyWritable": false,
"columnClassName": "java.lang.String"
}, {
"ordinal": 1,
"autoIncrement": false,
"caseSensitive": false,
"searchable": true,
"currency": false,
"nullable": 2,
"signed": false,
"displaySize": 2147483647,
"label": "biz_type",
"columnName": "biz_type",
"schemaName": "",
"precision": 2147483647,
"scale": 0,
"tableName": "",
"catalogName": "",
"type": {
"type": "scalar",
"id": 12,
"name": "varchar",
"rep": "STRING"
},
"readOnly": true,
"writable": false,
"definitelyWritable": false,
"columnClassName": "java.lang.String"
}, {
"ordinal": 2,
"autoIncrement": false,
"caseSensitive": false,
"searchable": true,
"currency": false,
"nullable": 2,
"signed": false,
"displaySize": 2147483647,
"label": "client_type",
"columnName": "client_type",
"schemaName": "",
"precision": 2147483647,
"scale": 0,
"tableName": "",
"catalogName": "",
"type": {
"type": "scalar",
"id": 12,
"name": "varchar",
"rep": "STRING"
},
"readOnly": true,
"writable": false,
"definitelyWritable": false,
"columnClassName": "java.lang.String"
}, {
"ordinal": 3,
"autoIncrement": false,
"caseSensitive": false,
"searchable": true,
"currency": false,
"nullable": 2,
"signed": false,
"displaySize": 2147483647,
"label": "biz_name",
"columnName": "biz_name",
"schemaName": "",
"precision": 2147483647,
"scale": 0,
"tableName": "",
"catalogName": "",
"type": {
"type": "scalar",
"id": 12,
"name": "varchar",
"rep": "STRING"
},
"readOnly": true,
"writable": false,
"definitelyWritable": false,
"columnClassName": "java.lang.String"
}, {
"ordinal": 4,
"autoIncrement": false,
"caseSensitive": false,
"searchable": true,
"currency": false,
"nullable": 2,
"signed": false,
"displaySize": 2147483647,
"label": "env",
"columnName": "env",
"schemaName": "",
"precision": 2147483647,
"scale": 0,
"tableName": "",
"catalogName": "",
"type": {
"type": "scalar",
"id": 12,
"name": "varchar",
"rep": "STRING"
},
"readOnly": true,
"writable": false,
"definitelyWritable": false,
"columnClassName": "java.lang.String"
}],
"sql": null,
"parameters": [],
"cursorFactory": {
"style": "LIST",
"clazz": null,
"fieldNames": null
},
"statementType": null
},
"firstFrame": {
"offset": 0,
"done": true,
"rows": [
["fb7e61aea7190331d8cebc9d35162327", "7", "1", "gggggg", "0", "2.1.4", "1656791999000", "1656791999213", "12333333333333", "-1", "7983397615961344", "7983397615961344", "113.110.110.110", "阿萨德", "南方", "仓储", "联通"],
["f5d24107070b403b83fdd4a92cd5de33", "1", "5", "hhhhhh", "1", "2.0.5", "1656792000000", "1656792000357", "45666666666666", "-1", "-1", "-1", "110.110.110.241", "中国", "是是是", "", "阿萨德"]
]
},
"updateCount": -1,
"rpcMetadata": {
"response": "rpcMetadata",
"serverAddress": "tx-bj-服务器"
}
}]
}
pS.close();
{"request":"closeStatement","connectionId":"17810271-59a0-4ae1-a764-073be9048ebd","statementId":1479}
{"response":"closeStatement",
"rpcMetadata":{"response":"rpcMetadata","serverAddress":"tx-bj-bdg-服务器:5888"}}
connection.close();
{"request":"closeConnection","connectionId":"17810271-59a0-4ae1-a764-073be9048ebd"}
{"response":"closeConnection",
"rpcMetadata":{"response":"rpcMetadata","serverAddress":"tx-bj-服务器:5888"}}