This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Journey To Enterprise Agility and have Daryl Kulak & Hong Li on-line!
See this thread for details.
Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

create tables using java code by fetching from .sql file  RSS feed

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Where is the problem??
 
Sashidhar Rao Gopisetty
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • 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
  • 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
Marshal
Posts: 38504
653
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • 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
Marshal
Posts: 38504
653
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!