• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please help

 
Vinay Gangoli
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a file.sql with all the insert commands written in it. Now i want to write jdbc code to simply run the entire file instead of creating multiple insert commands in jdbc and executing them individually. How do i do this.
greatly appreciate any help in this regard,
Vinay
 
Sri Basavanahally
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vinay,
You are going to have to read this file in your code and "feed" the output to JDBC to run against the DB. I don't see how you can run the file itself. May be you can, I don't know.
I like what your signature says
 
Vinay Gangoli
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats what i was thinking too...but fishing for a better solution anyway.
 
Mani Ram
Ranch Hand
Posts: 1140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can think of only 2 ways.
1. As suggested previously, read the file line by line and execute them
2. Make the bunch of SQL statements as a Stored procedure and execute it using CallableStatement.
 
Vinay Gangoli
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Make the bunch of SQL statements as a Stored procedure and execute it using CallableStatement."
I like this solution...never tried it before...Thanks Mani.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic