Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Please help

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic