yoyosir
yoyosir

Reputation: 458

How to use java to execute some 'source' commands in mysql?

I have a large number of source commands to execute. So I want to write some Java code to do this. Is there a way to do this in Java?

source command is like this:

 mysql> source /home/liova/download/tpch/queries/Q1.sql;

Upvotes: 0

Views: 1974

Answers (2)

Phalgun D
Phalgun D

Reputation: 21

You can use Runtime class to execute any commands in java. It executes the command as seperate process.

Upvotes: 0

Abdullah Jibaly
Abdullah Jibaly

Reputation: 54790

You can execute any shell command using Runtime.exec:

Runtime.exec("mysql db_name < /home/liova/download/tpch/queries/Q1.sql");

Upvotes: 1

Related Questions