?
Solved

Calling a SQL file from with JAVA

Posted on 2003-02-21
5
Medium Priority
?
435 Views
Last Modified: 2010-05-18
Hi,
I wanted to know if there is way of calling an entire SQL file(multiple sql calls n include sqlplus calls like spool) in Java. I would really appreciate an answer.

Thanks
Masky
0
Comment
Question by:masky007
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 3

Accepted Solution

by:
allahabad earned 150 total points
ID: 7996623
Runtime.getRuntime().exec("sqlplusConnection @sqlFile");

for example:
Runtime.getRuntime().exec("C:\\oracle\\ora90\\BIN\\sqlplusw.exe scott/tiger@localhost @c:\\xx\\test.sql");
0
 
LVL 3

Expert Comment

by:allahabad
ID: 7996742
If you want to exit also from sqlplus through java.

public class RunSQL {


   public static void main (String args[]){


      try {
       
         Process process=Runtime.getRuntime().exec("C:\\oracle\\ora90\\BIN\\sqlplusw.exe scott/tiger@localhost @c:\\xx\\test.sql");
         Thread.sleep(3000); // if want to see output
         process.destroy(); // exit sqlplus session
       
      }
      catch(Exception e){

         e.printStackTrace();
      }


   }


}
0
 

Author Comment

by:masky007
ID: 8028192
thanx allahabad...it really helped
0
 
LVL 3

Expert Comment

by:allahabad
ID: 8028333
Welcome.
0
 
LVL 1

Expert Comment

by:Computer101
ID: 8191963
A request has been made to change the grade,  The expert feels the current grade does not fit the criteria of the intended guidelines.  Those guidelines are below.  If no response, I will review this question and grade accordingly..

Computer101
E-E Admin

How Do I Know What Grade to Give?
Although we use an A-D scale here at Experts Exchange, it works differently than, say, school grades. If one or more Experts' proposals are accepted as answers, they should usually be given an A or B grade, since they have taken the time to provide you with a working solution. If a possible solution is incomplete - ask for clarification or details before accepting the answer and grading it. People should not be given lower grades because of incorrect grammar or because you just accepted their answer or comment to close the question. Keep in mind, your question and any follow-up comments should be focused so that there can be a specific answer. The following is a good guideline to follow when grading:

A: The Expert(s) either provided you with a thorough answer or they provided you with a link to information that thoroughly answered your question. An "A" can also be given to any answer that you found informative or enlightening beyond the direct question that you asked.

B: The Expert(s) provided an acceptable solution, or a link to an acceptable solution, that you were able to use, although you may have needed a bit more information to complete the task.

C: Because Experts' reliability are often judged by their grading records, many Experts would like the opportunity to clarify if you have questions about their solutions. If you have given the Expert(s) ample time to respond to your clarification posts and you have responded to each of their posts providing requested information; or if the answers, after clarification, lack finality or do not completely address the issue presented, then a "C" grade is an option. You also have the option here of just asking Community Support to delete the question.

Remember, the Expert helping you today is probably going to be helping you next time you post a question. Give them a fair chance to earn an 'Excellent!' grade and they'll provide you with some amazing support.
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This video teaches viewers about errors in exception handling.
Suggested Courses
Course of the Month13 days, 20 hours left to enroll

800 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question