• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Please help

 
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
 
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.
 
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.
 
Yes, of course, and I accept that blame. In fact, i covet that blame. As does this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic