run java program in debian 10 command line with external jar - java

I'm using postgresql-42.2.23.jar in my following program.i have tested the code in windows environment in intelij ide and it is working fine.But i want to run it in the linux machine( which runs debian 10)using the comand line.Right now postgresql-42.2.23.jar file and java class files are in the Music folder.
when i compile the program with
"chathu#giottestserver:~/Music$ javac -cp Music/postgresql-42.2.23.jar serverinsert.java"
command,it compiles and create the class file.
But when i run it with
"chathu#giottestserver:~/Music$ java -cp .:Music/postgresql-42.2.23.jar:serverinsert"
it gives following messageenter image description here
I have tried with following command also.But no output.
" chathu#giottestserver:~/Music$ java -cp .:Music/postgresql-42.2.23.jar serverinsert"
can anyone help me to solve this?
import java.sql.*;
import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;
public class serverinsert {
public static void main(String []V){
Connection c = null;
Statement stmt = null;
try
{
//Connecting to the database in local machine
Class.forName("org.postgresql.Driver");
c = DriverManager
.getConnection("jdbc:postgresql://localhost/",
"postgres", "gflow123");
System.out.println("Opened database successfully");
//Creation of a table to insert data in the local machine
stmt = c.createStatement();
String sql = "CREATE TABLE jason " +
"(ID INT NOT NULL," +
" sendata json NOT NULL)";
stmt.executeUpdate(sql); //updates the table
System.out.println("Table created successfully");
//Opening connection for DLC client
ServerSocket ss = new ServerSocket(4000);
Socket s = ss.accept();
StringBuilder sb = new StringBuilder();
BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()));
String line;
// DataOutputStream Dout = new DataOutputStream(s.getOutputStream());
// BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
//String MsgIn="",MsgOut="";
// inserting the DLC Data into a string variable called content
String content="";
while((line = br.readLine()) != null){
sb.append(line).append(System.lineSeparator());
content = sb.toString();
}
//Removing the http header content from the DLC Data
String jsn=content.substring(content.indexOf("{"));
//DLC received data processing
System.out.println(jsn);
String jsonreplacd=jsn.replace("[{\"name","\"name");
System.out.println(jsonreplacd);
String jsonreplacd1=jsonreplacd.replace("\"name","[\"INSERT INTO jason (ID,sendata) \" + \"VALUES ('1','')");
System.out.println(jsonreplacd1);
String jsonreplacd2=jsonreplacd1.replace("')\":\"press\",\"datatype\":\"float\",\"content\":","");
System.out.println(jsonreplacd2);
String jsn2=jsonreplacd2.substring(jsonreplacd2.indexOf("["));
System.out.println(jsn2);
String jsn3=jsn2.replace("[{","{");
System.out.println(jsn3);
String jsn4=jsn3.replace("\"t\"","\\\"t\\\"");
System.out.println(jsn4);
String jsn5=jsn4.replace("\"v\"","\\\"v\\\"");
System.out.println(jsn5);
String jsn6=jsn5.replace(":",":\\\"");
System.out.println(jsn6);
String jsn7=jsn6.replace(",\\","\\\",\\");
System.out.println(jsn7);
String jsn8=jsn7.replace("},","\\\"},");
System.out.println(jsn8);
String jsn9=jsn8.replace("}]}]}}","\\\"}')\"");
System.out.println(jsn9);
String jsn10=jsn9.replace("[","");
System.out.println(jsn10);
String jsn11=jsn10.replace("},{","}')\",\"INSERT INTO jason (ID,sendata) \" + \"VALUES ('1','{");
System.out.println(jsn11);
String jsn12=jsn11.replace("\",\"","\"#\"");
System.out.println(jsn12);
// String jsn3=jsn2.replace("\"","\\\"");
//
//
// String jsn6=jsn5.replace(",","\\\",");
// String jsn7=jsn6.
//
// String jsn9=jsn8.replace("}\\\"","}");
// System.out.println(jsn9);
// Creation of string array type to execute sql command
//String[] strArray = new String[] {jsn11};
//System.out.println(strArray[0]);
//String hi="hi";
//String[] data = {"INSERT INTO jason (ID,sendata) " + "VALUES ('1','{\"t\":\"2104492460\",\"v\":\"-0.000769\"}')"};
String[] data = jsn12.split("#");
for(int i=0;i<5;i++) {
//stmt.executeUpdate(data[i]);
System.out.println(data[i]);
}
s.close();
}
catch(Exception e){
}
}
}

You are trying to run application with postgresql-42.2.23.jar dependency.
"javac -cp Music/postgresql-42.2.23.jar serverinsert.java" - works, as syntax is correct
"java -cp .:Music/postgresql-42.2.23.jar:serverinsert" - does not work, because serverinsert is not a .jar file (see also this)
"java -cp .:Music/postgresql-42.2.23.jar serverinsert" - normally it shall work, but you did not post your "serverinsert" code. Instead we have "writedbtst", which I believe is your entry point (method main) and you shall run it instead of "serverinsert". You could save it as "serverinsert.java" if it was not public.
To sum up, If it works in your IDE, try running it on the same platform using command line and replacing main class accordingly. And please follow java class naming conventtion.

Related

Display status message based on application status in Linux server

I have a linux server in which my Java application(Jar) is runnning, I check this with command ps -ef | grep 'myapp.jar' and get 2 line output which states my app is Up and running.
Now we have one Web UI application. I want to show in the UI a status message like "My application is Up/Down" depending on my jar is running or stopped on the linux server.
How do i achieve this?
You can use jcmd.
Suppose the myapp.jar bootstrap class is com.myapp.Main then this fragment of code may help you:
Runtime rt = Runtime.getRuntime();
String[] commands = {"jcmd"};
Process proc = rt.exec(commands);
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(proc.getInputStream()));
// read the output from the command
String s = null;
while ((s = stdInput.readLine()) != null) {
String[] out = s.split("\\s");
if("com.myapp.Main".equals(out[1])) {
System.out.println("is running");
}
}
Since you don't mention which application server you're running, I'm just going to go ahead and assume Apache Tomcat. If that is not the case, this answer will be absolutely useless.
If you have Tomcat Manager enabled or are willing to enable it, you can list currently running applications from it.
An example from a Tomcat server running just one application, "myWebApp", along with several default applications:
OK - Listed applications for virtual host localhost
/:running:0:ROOT
/myWebApp:running:0:myWebApp
/examples:running:0:examples
/host-manager:running:0:host-manager
/jsp:running:0:jsp
/manager:running:1:manager
/docs:running:0:docs
In order to use Tomcat Manager, you also need to enable at least one user with appropriate role in Tomcat. In Tomcat 7 the required role is manager-script, so you'd have to add following lines into $CATALINA_HOME/conf/tomcat-users.xml in order to add user called "status" with password "password" (please change these to something more reasonable):
<role rolename="manager"/>
<user username="status" password="password" roles="manager-script"/>
After you have enabled a user capable of querying Tomcat Manager, you can simply ask it to give you status of all running applications. Parsing text mode output is simple enough to give you a working example:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.StringBuilder;
import java.net.URL;
import java.net.URLConnection;
import java.util.Base64;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class TomcatWebappStatus {
// This is cooked together from examples found in:
// http://stackoverflow.com/questions/4328711
// http://stackoverflow.com/questions/4883100
private String getAppStatus(String url,
String app,
String user,
String pass) throws Exception {
BufferedReader in;
Matcher m;
Pattern p = Pattern.compile("^/\\w+:(\\w+):(\\d+):" + app + "$");
String auth = user + ":" + pass;
String resp = "ERROR (application " + app + " not found)";
URL website = new URL(url);
URLConnection connection;
connection = website.openConnection();
if (user != null && user.length() > 0 &&
pass != null && pass.length() > 0) {
connection.setRequestProperty("Authorization",
"Basic " + Base64.getEncoder().encodeToString(auth. getBytes()));
}
in = new BufferedReader( new InputStreamReader(
connection.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
m = p.matcher(inputLine);
if (m.find()) resp = m.group(1);
}
in.close();
return resp.toString();
}
public static void main(String[] argv) throws Exception {
TomcatWebappStatus t = new TomcatWebappStatus();
String tomcatManagerURL = "http://localhost:8080/manager/text/list";
String appName = argv[0];
String tomcatManagerUsername = argv[1];
String tomcatManagerPassword = argv[2];
String s = t.getAppStatus(tomcatManagerURL,
appName,
tomcatManagerUsername,
tomcatManagerPassword);
System.out.println("App \"" + appName + "\" is " + s);
}
}
If you crank out bytecode from the example above, you should be able to run it locally against Tomcat 7 (at least, might work with other versions as well).
Should your your Web UI happen to be made with Java, you could plug that example into it. In case of javascript, query to /manager/text/list and parsing its output should do the trick.

Passing windows credentials programmatically

I have a VB script to which I need to pass username and password.
I want to run this VB script through Java code programmatically.
Is there a way that I can pass the Windows credentials to the VB script in Java programmatically?
You can have the credentials on the OS environment and read them from there:
String credentials = System.getenv().get("encrypted_credentials_or_something");
And then run your command from Java. However, Runtime.exec() won't work in some cases:
When the command is not on the System's PATH
When arguments are involved
When you want to have access to the process output
When you need to be able to kill the process
When you need to check if it terminated successfully or in error (status code != 0 - which is why you write System.exit(int) to terminate a Java application. The System.exit(1), for example, indicates abnormal termination)
That's why I created this utility class to execute external processes with arguments and everything. It works very well for me:
import java.io.*;
import java.util.*;
public class ExternalCommandHelper {
public static final void executeProcess(File directory, String command) throws Exception {
InputStreamReader in = null;
try {
//creates a ProcessBuilder with the command and its arguments
ProcessBuilder builder = new ProcessBuilder(extractCommandWithArguments(command));
//errors will be printed to the standard output
builder.redirectErrorStream(true);
//directory from where the command will be executed
builder.directory(directory);
//starts the process
Process pid = builder.start();
//gets the process output so you can print it if you want
in = new InputStreamReader(pid.getInputStream());
//simply prints the output while the process is being executed
BufferedReader reader = new BufferedReader(in);
String line = null;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
int status = 0;
//waits for the process to finish. Expects status 0 no error. Throws exception if the status code is anything but 0.
if ((status = pid.waitFor()) != 0) {
throw new IllegalStateException("Error executing " + command + " in " + directory.getAbsolutePath() + ". Error code: " + status);
}
} finally {
if (in != null) {
in.close();
}
}
}
//Splits the command and arguments. A bit more reliable than using String.split()
private static String[] extractCommandWithArguments(String command) {
StringTokenizer st = new StringTokenizer(command);
String[] cmdWithArgs = new String[st.countTokens()];
for (int i = 0; st.hasMoreTokens(); i++) {
cmdWithArgs[i] = st.nextToken();
}
return cmdWithArgs;
}
}

External python application is not running

Hi i just create a java application to run my python code externally. But it want giving me the out put.
this is my java code:-
package com.epatient;
import java.io.*;
public class InterpreterExample {
//static String workingDir = System.getProperty("user.dir");
//static String appDir = workingDir + "\\epatient\\epatient_prediction.py";
public static void main(String a[]){
try{
String appDir = "C:\\Users\\Thushara Kasun\\Documents\\juno\\serial.port\\epatient\\epatient_prediction.py";
System.out.println(appDir);
ProcessBuilder pb = new ProcessBuilder("python",appDir);
Process p = pb.start();
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));
String ret = in.readLine();
System.out.println("value is : "+ret);
}catch(NumberFormatException e){e.printStackTrace();}
catch (IOException e) {e.printStackTrace();}
}
}
this is my python code :-
import sys
from sklearn.externals import joblib
import pandas as pd
import numpy as np
import csv
from sklearn.decomposition import PCA
import re
import psycopg2
import datetime
import time
con = None
bio_data = None
heart_rate = None
so2_data = None
temp_data = None
bp_data = None
try:
con = psycopg2.connect(database='Epatient_user_1', user='postgres', password='root')
cur = con.cursor()
...#database access codes omited
model_name = 'trained_model'
est = joblib.load(model_name)
predictions = est.predict(data)
#predictions
# <codecell>
#sys.stdout.write(str(int(predictions[0])))
#sys.stdout.flush()
#print int(predictions[0])
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
#print st
cur.execute('INSERT INTO patient_status (STATUS,TIME,PROCESSED) VALUES (' + str(int(predictions[0])) + ',\''+ st + '\',0);')
con.commit()
except psycopg2.DatabaseError, e:
print 'Error %s' % e
sys.exit(1)
finally:
if con:
con.close()
sys.stdout.write(str(int(predictions[0])))
sys.stdout.flush()
#print int(predictions[0])
Java out put is just value is : null
there is no problem with the python code it is working perfectly. i just want to print a Boolean which is in a string format. simultaneously i need to update that value in my local postgresql database(via python code, which is working individually). simply the python code is not executing by my java application. Kindly help me on this or give me a alternative way to resolve this issue.
I think that your Java code is Ok, then try to change your Python script.
Please, would you be so kind to change the line print int(predictions[0]) with:
sys.stdout.write(str(predictions[0]))
sys.stdout.flush()
sys.stdout will print data to console outputstream
and just for testing, put the absolute path of your script in the ProcessBuilder constructor:
String appDir = "C:\\my\\full\\path\\to\\script.py";
ProcessBuilder pb =
new ProcessBuilder("python", appDir);
Process p = pb.start();
....

ProcessBuilder - A potential bug

I am having a strange issue when trying to execute a block of code (more particularly the ProcessBuilder class in Java)
Code that works:
package modules.user.verify;
import java.io.*;
import java.util.*;
import java.net.*;
public class VerifyUser {
public static void main(String[] args) {
boolean listening = true;
try {
ServerSocket server = new ServerSocket(20002);
while(listening) {
Socket client = server.accept();
PrintWriter out = new PrintWriter(client.getOutputStream(), true);
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
String input, store = "", request = "";
// For all input received, write it to the request buffer.
while((input = in.readLine()) != null) {
request += input;
} // end while loop
BufferedReader reader = new BufferedReader(new FileReader("store/address-book/address-book.xml"));
while((input = reader.readLine()) != null) {
store += input;
} // end while loop
String acl2 = "(include-book \"modules/user/verify/verify-user\")" +
"(in-package \"ACL2\")" +
"(set-state-ok t)" +
"(set-guard-checking :none)" +
"(testUser \"" + request + "\" \"" + store + "\" state)";
System.out.println("Executing ACL2 runtime...");
ProcessBuilder processBuilder = new ProcessBuilder("acl2");
File log = new File("logs/user/verify/acl2_log.txt");
processBuilder.redirectErrorStream(true);
processBuilder.redirectOutput(ProcessBuilder.Redirect.appendTo(log));
Process process = processBuilder.start();
PrintWriter procIn = new PrintWriter(process.getOutputStream());
// Write the ACL2 to the process, exit ACL2 and close the socket
procIn.println(acl2);
procIn.println("(good-bye)");
procIn.flush();
procIn.close();
out.close();
in.close();
client.close();
} // end while loop
server.close();
System.exit(0);
} catch(Exception e) {
e.printStackTrace();
} // end try/catch
} // end function main
} // end class VerifyUser
Code that doesn't work:
package modules.user.register;
import java.io.*;
import java.util.*;
import java.net.*;
public class RegisterUser {
public static void main(String[] args) {
boolean listening = true;
try {
// Acquire the listening port for connection to client.
ServerSocket server = new ServerSocket(20001);
while(listening) {
// Wait until the client connects
Socket client = server.accept();
// Handles for input and output streams relating to the socket connection
PrintWriter out = new PrintWriter(client.getOutputStream(), true);
BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
// Buffers
String input, store="", request="";
// Read the input from the connection
while((input = in.readLine()) != null) {
request += input;
} // end while
// Read the contents of the address-book currently stored
BufferedReader reader = new BufferedReader(new FileReader("store/address-book/address-book.xml"));
while((input = reader.readLine()) != null) {
store += input;
} // end while
// The ACL2 code to execute.
String acl2 = "(include-book \"register-user\")" +
"(in-package \"ACL2\")" +
"(registerUser \"" + request + "\" \"" + store + "\" state)";
// Initialize ACL2 and dump its output to the log
System.out.println("Executing ACL2 runtime for RegisterUser...");
ProcessBuilder processBuilder = new ProcessBuilder("acl2");
File log = new File("logs/user/register/acl2_log.txt");
processBuilder.redirectErrorStream(true);
processBuilder.redirectOutput(ProcessBuilder.Redirect.appendTo(log));
Process process = processBuilder.start();
PrintWriter procIn = new PrintWriter(process.getOutputStream());
// Write the ACL2 to the process, close ACL2
//procIn.println(acl2);
//procIn.println("(good-bye)");
//procIn.flush();
//procIn.close();
// Old store is old address-book file and new store is newly generated
File oldStore = new File("store/address-book/address-book.xml");
File newStore = new File("store/address-book/temp_address-book.xml");
// Response header information
String response = "<?xml version='1.0'?>" +
"<!DOCTYPE response SYSTEM 'dtd/reponse.dtd'>" +
"<response>";
// Determine if there was a change.
// If entry was added, the length > that old length.
if(oldStore.length() < newStore.length()) {
// Replace old file with new file
oldStore.delete();
newStore.renameTo(oldStore);
// Extract data from request XML
String name = request.substring(request.indexOf("<name>")+6, request.indexOf("</name>")-7);
String domain = request.substring(request.indexOf("<domain>")+8, request.indexOf("</domain>")-9);
// Create the store directory for the user's emails
File storeDirectory = new File("store/email/" + domain + "/" + name + "/");
storeDirectory.mkdirs();
response += "<message>ACCEPT</message>";
} else {
// Remove new file as it is pointless
newStore.delete();
response += "<message>REJECT</message>";
} // end if-else
response += "</response>";
// Writeback the response to the client
out.print(response);
out.flush();
// Close all streams
out.close();
in.close();
client.close();
} // end while
} catch(Exception e) {
e.printStackTrace();
} // end try/catch
} // end function main
} // end class RegisterUser
As you can see, I am not passing any arguments the the program. when I echo %PATH% on my windows DOS shell, it shows that C:\ACL2 is in my ENV vars (which is the folder acl2.exe is located). I've tried changing the acl2 to C:\ACL2\acl2.exe only to have the same results.
What is boggling me is why the first one works perfect and the second one (with almost the same exact code - same exact ProcessBuilder code) does not work.
It appears this block of code is where my problem is:
System.out.println("Executing ACL2 runtime...");
ProcessBuilder processBuilder = new ProcessBuilder("acl2");
File log = new File("logs/user/register/acl2_log.txt");
processBuilder.redirectErrorStream(true);
processBuilder.redirectOutput(ProcessBuilder.Redirect.appendTo(log));
Process process = processBuilder.start();
PrintWriter procIn = new PrintWriter(process.getOutputStream());
The error:
Executing ACL2 runtime for RegisterUser...
java.io.IOException: Cannot run program "acl2": The system cannot find the path specified
at java.lang.ProcessBuilder.start(Unknown Source)
at modules.user.register.RegisterUser.main(RegisterUser.java:74)
Caused by: java.io.IOException: The system cannot find the path specified
at java.lang.ProcessImpl.openForAtomicAppend(Native Method)
at java.lang.ProcessImpl.newFileOutputStream(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 2 more
What is supposed to happen, is that the Process that gets started is the ACL2 environment, code is sent to it which is executed and then the process is killed (via the (good-bye) command in ACL2). After that the code should exit after a little bit of Java, which is not related to the ACL2 process where the error occurs.
The VerifyUser program invokes ACL2, writes a response to a "server-response.xml" file and exits gracefully without incident.
The RegisterUser program should invoke ACL2, write a response and exit gracefully, and a little java code creates a directory for a user and deletes a store file and renames the newly generated one for user registration.
Since the exception is thrown at
at java.lang.ProcessImpl.openForAtomicAppend(Native Method)
AND you use two different paths:
File log = new File("logs/user/verify/acl2_log.txt");
File log = new File("logs/user/register/acl2_log.txt");
it might be possible, that the acl command is found but that the redirection cannot be performed. In this case the error message is not quite helpful but - if you read between the lines - also not wrong.

Executing a .sql file through Java

I have a sql script file, i need to execute commands present in that through java. I searched in internet regarding the same, i got some code defining parsers to split the SQL statements and executing that. But none of them worked for my sql script file.Because my script file contains both create statements and alter statements without semicolon at the end[Instead it has GO]Can anybody suggest a solution to execute the script file?
Thanks,
Mahesh
For simple scripts I generally use this class from ibatis - ScriptRunner. Alternative you can spawn a new db client process from Java and feed in the script you wan't execute. This will work for all scripts, as simple solutions like ScriptRunner don't work well when the delimiters in the sql files get changed for instance.
Here's an example how to feed the sql as a string to a spawed db client process:
private void runSql(String pSql) {
String tCommand = "mysql -u " + username + (password != null ? " -p" + password : "") + " " + dbName;
System.out.println(tCommand);
try {
Process tProcess = Runtime.getRuntime().exec(tCommand);
OutputStream tOutputStream = tProcess.getOutputStream();
Writer w = new OutputStreamWriter(tOutputStream);
System.out.println(pSql);
w.write(pSql);
w.flush();
Scanner in = new Scanner(tProcess.getErrorStream());
String errorMessage = "";
while (in.hasNext()) {
errorMessage += in.next() + " ";
}
if (errorMessage.length() > 0) {
System.out.println(errorMessage);
throw new ClientSqlExecutionException(errorMessage);
}
} catch (IOException e) {
e.printStackTrace();
}
}
Have a look at Mybatis Migrations code, it does something like the one you need:
http://code.google.com/p/mybatis/wiki/Migration
You need to change the parser so it produces executable statements. But I'm not sure I understand what you mean when you say "execute through Java".
Java won't execute those SQL statements - the database you connect to will. Java can connect to a database using JDBC and send the SQL statements from the file.
I don't see why you have to parse the SQL, unless you want Java to validate them before sending them on to the database server. The server will parse and validate them again, so it feels like you're doing extra work for nothing.
The simplest solution I can present to you is this, presuming I understand your question.
1) Read text file into a string or array via Java IO.
2) Pass string or array to MySQL via JDBC.
Read from file example,
import java.io.*;
class FileRead
{
public static void main(String args[])
{
try{
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream("textfile.txt");
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By Line
while ((strLine = br.readLine()) != null) {
// Print the content on the console
System.out.println (strLine);
}
//Close the input stream
in.close();
}catch (Exception e){//Catch exception if any
System.err.println("Error: " + e.getMessage());
}
}
}
acquired from, http://www.roseindia.net/java/beginners/java-read-file-line-by-line.shtml
The simplest way is to simply get the statements and check if they need they semi-column at the end: (this is an example and only works if it is a statement by line:
public void executeScript(String script) {
BufferedReader in = new BufferedReader(new FileReader(script));
while (in.read() > 0) {
String statement = in.readLine();
statement = statement.trim().toLowerCase();
String command = statement.split("[ ]+")[0]; // split the statement.
if (command.equals("insert") || command.equals("update") /* || any other */) {
statement = statement + ";";
}
// execute statement using jdbc
}
}
If you do not know how to use jdbc, just ask :-)
Use this slightly modified version of the com.ibatis.common.jdbc.ScriptRunner class which is fully self contained, i.e. you do not need to have any third party jar dependencies.
It is possible to change the delimiter from ; to GO. I think that should do the trick.
Here is an example:
Reader reader = new BufferedReader(*** Your FileReader instance ***);
try
{
ScriptRunner runner = new ScriptRunner(connection, false, true);
runner.setDelimiter("GO", true);
runner.runScript(reader);
}
finally
{
reader.close();
}
Apache Ant SQL Task worked for me.
https://ant.apache.org/manual/Tasks/sql.html

Categories