|
|
|
@ -19,6 +19,7 @@ import at.compax.tools.sql.ConnectionParameters;
|
|
|
|
|
import at.compax.tools.sql.FrogConnection;
|
|
|
|
|
import at.compax.tools.sql.SqlExecutionException;
|
|
|
|
|
import at.compax.tools.sql.SqlExecutor;
|
|
|
|
|
import at.compax.tools.sql.model.QueryParameter;
|
|
|
|
|
import at.compax.tools.sql.model.QueryResult;
|
|
|
|
|
import at.compax.tools.sql.model.Result;
|
|
|
|
|
import at.compax.tools.sql.model.UserError;
|
|
|
|
@ -185,10 +186,13 @@ public class Main {
|
|
|
|
|
if (!"--- END ---".equals(line)) {
|
|
|
|
|
commandBuffer.append(line).append("\n");
|
|
|
|
|
} else {
|
|
|
|
|
String query = commandBuffer.toString().trim();
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
QueryParameter queryParameter = mapper.readValue(commandBuffer.toString(), QueryParameter.class);
|
|
|
|
|
|
|
|
|
|
String query = queryParameter.getSql();
|
|
|
|
|
String result;
|
|
|
|
|
if (query.toLowerCase().startsWith("select")) {
|
|
|
|
|
result = formatJsonObject(SqlExecutor.executeQuery(conn, query, null));
|
|
|
|
|
result = formatJsonObject(SqlExecutor.executeQuery(conn, query, queryParameter.getRowLimit()));
|
|
|
|
|
} else if (query.toLowerCase().startsWith("update") || query.toLowerCase().startsWith("insert")) {
|
|
|
|
|
result = formatJsonObject(SqlExecutor.executeUpdate(conn, query));
|
|
|
|
|
} else {
|
|
|
|
|