|
|
@ -192,11 +192,13 @@ public class Main {
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
QueryParameter queryParameter = mapper.readValue(commandBuffer.toString(), QueryParameter.class);
|
|
|
|
QueryParameter queryParameter = mapper.readValue(commandBuffer.toString(), QueryParameter.class);
|
|
|
|
|
|
|
|
|
|
|
|
String query = queryParameter.getSql();
|
|
|
|
String query = queryParameter.getSql().trim();
|
|
|
|
String result;
|
|
|
|
String result;
|
|
|
|
if (query.toLowerCase().startsWith("select")) {
|
|
|
|
if (query.toLowerCase().startsWith("select")) {
|
|
|
|
result = formatJsonObject(SqlExecutor.executeQuery(conn, query, queryParameter.getRowLimit()));
|
|
|
|
result = formatJsonObject(SqlExecutor.executeQuery(conn, query, queryParameter.getRowLimit()));
|
|
|
|
} else if (query.toLowerCase().startsWith("update") || query.toLowerCase().startsWith("insert")) {
|
|
|
|
} else if ( query.toLowerCase().startsWith("update")
|
|
|
|
|
|
|
|
|| query.toLowerCase().startsWith("insert")
|
|
|
|
|
|
|
|
|| query.toLowerCase().startsWith("delete")) {
|
|
|
|
result = formatJsonObject(SqlExecutor.executeUpdate(conn, query));
|
|
|
|
result = formatJsonObject(SqlExecutor.executeUpdate(conn, query));
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
result = formatJsonObject(SqlExecutor.execute(conn, query));
|
|
|
|
result = formatJsonObject(SqlExecutor.execute(conn, query));
|
|
|
|