0

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;
Franz Kafka
  • 10,623
  • 20
  • 93
  • 149
yoyosir
  • 458
  • 2
  • 11
  • 27

2 Answers2

1

You can execute any shell command using Runtime.exec:

Runtime.exec("mysql db_name < /home/liova/download/tpch/queries/Q1.sql");
Abdullah Jibaly
  • 53,220
  • 42
  • 124
  • 197
0

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

Phalgun D
  • 21
  • 1