• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

create tables using java code by fetching from .sql file

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have to prepare a javcode which creates tables by accepting sql file name.
connection to DB will be established by properties file.it will be gernalised so that any DB can be connected which specify in properties and any statement can be executed given in sql file.
please it is urgent.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Where is the problem??
 
Sashidhar Rao Gopisetty
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i have a problem to fetch sql file in the java file
 
Sashidhar Rao Gopisetty
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i mean to say that i dont know how to create tables by fetching from sql file name as a parameter to the java function which will execute.
 
author & internet detective
Posts: 41855
904
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sashidhar,
That's still pretty broad. Which of the following are you having trouble with?

1) Reading a file to get a name
2) Creating a table in SQL
3) Making a JDBC call
 
Sashidhar Rao Gopisetty
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i want to write a java code in which i have to call a function to create sql tables and insert data into those table at once.

1.connection established by the code using properties file. (its done)
2.create tables and insert data ito tables script is prepared and store ina x.sql file.(executed and tested.its done)
3.now i have to call the file x.sql file in the code and execute the script in that file at once, in the function i will take two parameters one properties file name two sql file name.(this is what i dont know)
please send me any code snippet matching this requirement
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If sounds like your problem is File I/O, not SQL. Your problem is reading the file, yes?

Take a look at the java.io.File class and its related classes - java.io.FileInputStream (or java.io.FileReader) is what you probably want to use in this case.
 
Jeanne Boyarsky
author & internet detective
Posts: 41855
904
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sashidhar Rao Gopisetty:
now i have to call the file x.sql file in the code and execute the script in that file at once, in the function i will take two parameters one properties file name two sql file name.(this is what i dont know)
please send me any code snippet matching this requirement


I agree with Joel that this is an I/O question, so I am moving it to our I/O forum.

For some examples of how to read a file, take a look at Sun's

I/O tutorial.
 
In the renaissance, how big were the dinosaurs? Did you have tiny ads?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic