Forums Register Login

Run .sql file using JDBC or any java API

+Pie Number of slices to send: Send
Hi ranchers,

This is Venkat. I am currently developing a installer. This intaller has a task of running initial database scripts (.sql file) on a database server.

Is there any way that i can run .sql file using JDBC or hibernate or any other API's.

The intital scripts include,

1) user creation script.
2) create tables for above created user.


Please help me as soon as possible.

Thanks in advance,
Venkat
+Pie Number of slices to send: Send
Java has an IO API you can use to access the file - see the java.io package. Once you have the contents of the file its easy to run them via JDBC or Hibernate.
+Pie Number of slices to send: Send
You can read the file one sql statement at the time and execute it through the JDBC.

for oracle the single line sqls like select, inser etc are terminated by ';'
and PL SQL blocks by '/' so you can use these separators to distinguish the sql sattements
For my next trick, I'll need the help of a tiny ad ...
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 4312 times.
Similar Threads
running sql script file from java
Need to run db scripts using java
Need a help regarding .....
Directly run SQL Script file using JDBC
Is it possible to directly run SQL Script file using JDBC
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 03:20:47.