This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Run .sql file using JDBC or any java API

 
Venkata Sirish
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Manish Singh
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic