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,303
  • 19
  • 89
  • 148
yoyosir
  • 438
  • 1
  • 11
  • 26

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
  • 50,216
  • 39
  • 119
  • 196
0

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

Phalgun D
  • 21
  • 1