|
|
|
@ -3,6 +3,7 @@ package at.compax.tools.sql.main;
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
import java.nio.charset.Charset;
|
|
|
|
|
import java.sql.Connection;
|
|
|
|
|
import java.sql.DriverManager;
|
|
|
|
|
import java.sql.SQLException;
|
|
|
|
@ -94,22 +95,59 @@ public class Main {
|
|
|
|
|
return sb.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void runTests() {
|
|
|
|
|
try {
|
|
|
|
|
// String stdInSql = readFromStdIn();
|
|
|
|
|
|
|
|
|
|
@Cleanup
|
|
|
|
|
Connection conn = getConnection("172.19.13.66", 1521L, "aax2qc", "aax2qc", "aax2qc");
|
|
|
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
|
|
|
|
|
System.out.println(mapper.writeValueAsString(compileExampleSpec(conn)));
|
|
|
|
|
System.out.println(mapper.writeValueAsString(compileExampleSpecWithErrors(conn)));
|
|
|
|
|
System.out.println(mapper.writeValueAsString(executeExampleQueryWithException(conn)));
|
|
|
|
|
System.out.println(mapper.writeValueAsString(executeExampleQueryWithoutParameter(conn)));
|
|
|
|
|
System.out.println(mapper.writeValueAsString(executeExampleQueryWithParameter(conn)));
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void main(String[] args) throws Exception {
|
|
|
|
|
BasicConfigurator.configure();
|
|
|
|
|
LogManager.getLogger("at.compax.tools.sql.main").setLevel(Level.ALL);
|
|
|
|
|
LogManager.getLogger("at.compax.tools.sql").setLevel(Level.ALL);
|
|
|
|
|
|
|
|
|
|
// String stdInSql = readFromStdIn();
|
|
|
|
|
|
|
|
|
|
@Cleanup
|
|
|
|
|
Connection conn = getConnection("172.19.13.66", 1521L, "aax2qc", "aax2qc", "aax2qc");
|
|
|
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper();
|
|
|
|
|
|
|
|
|
|
System.out.println(mapper.writeValueAsString(compileExampleSpec(conn)));
|
|
|
|
|
System.out.println(mapper.writeValueAsString(compileExampleSpecWithErrors(conn)));
|
|
|
|
|
System.out.println(mapper.writeValueAsString(executeExampleQueryWithException(conn)));
|
|
|
|
|
System.out.println(mapper.writeValueAsString(executeExampleQueryWithoutParameter(conn)));
|
|
|
|
|
System.out.println(mapper.writeValueAsString(executeExampleQueryWithParameter(conn)));
|
|
|
|
|
if (args.length == 0) {
|
|
|
|
|
runTests();
|
|
|
|
|
} else {
|
|
|
|
|
if (args.length < 4)
|
|
|
|
|
throw new IllegalArgumentException("Arguments: Host Port sid username password");
|
|
|
|
|
|
|
|
|
|
String host = args[0];
|
|
|
|
|
long port = Long.parseLong(args[1]);
|
|
|
|
|
String sid = args[2];
|
|
|
|
|
String username = args[3];
|
|
|
|
|
String password = args[4];
|
|
|
|
|
|
|
|
|
|
@Cleanup
|
|
|
|
|
Connection conn = getConnection(host, port, sid, username, password);
|
|
|
|
|
|
|
|
|
|
BufferedReader br = new BufferedReader(new InputStreamReader(System.in, Charset.forName("UTF-8")));
|
|
|
|
|
String line;
|
|
|
|
|
StringBuffer commandBuffer = new StringBuffer();
|
|
|
|
|
|
|
|
|
|
while ((line = br.readLine()) != null) {
|
|
|
|
|
if (!"--- END ---".equals(line)) {
|
|
|
|
|
commandBuffer.append(line);
|
|
|
|
|
} else {
|
|
|
|
|
System.out.println(mapper.writeValueAsString(SqlExecutor.executeQuery(conn, commandBuffer.toString())));
|
|
|
|
|
commandBuffer.setLength(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|