File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes Running .sql File in java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Running .sql File in java" Watch "Running .sql File in java" New topic

Running .sql File in java

Amit Lonkar

Joined: Dec 12, 2001
Posts: 25
Hi all
I have to run a a ".sql" file through java. Can anyone tell how it can be done.
Amit Lonkar
Arun Boraiah
Ranch Hand

Joined: Nov 28, 2001
Posts: 233
i guess ".sql" file you are talking contains set of sql statements. Hence you can write the stored procedure in the back end and execute the same using java.

Sharing is learning
Amit Lonkar

Joined: Dec 12, 2001
Posts: 25
I am using Mysql. So stored procedures might not be possible.
One way i found out is, I need the command
mysql --execute="c:/test.sql" to be execute. I put this in a batch file, and ran the batch file using Runtime class.
Amit Lonkar
I agree. Here's the link:
subject: Running .sql File in java
jQuery in Action, 3rd edition