Results 1 to 7 of 7
  1. #1
    renu is offline Senior Member
    Join Date
    May 2010
    Posts
    117
    Rep Power
    0

    Question how to display only the error message and exit

    Hi

    I execute a procedure from java passing parameters . If the parameters are given wrong , the procedure returns an error message . I need to return only the error message to the console and exit.

    MY code writtens the error message and other oracle error messages along with it. How to get only the error message on the console?

    XML Code:
    java.sql.SQLException: ORA-20910: A SCNV_ID COULD NOT BE LOCATED
    ORA-06512: at "SCHOOL.PKG_COMPARE", line 69
    ORA-06512: at line 1
    
    	at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:331)
    	at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:288)
    	at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:745)
    	at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:218)
    	at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:969)
    	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1190)
    	at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3370)
    	at oracle.jdbc.driver.OraclePreparedStatement.execute(OraclePreparedStatement.java:3476)
    	at oracle.jdbc.driver.OracleCallableStatement.execute(OracleCallableStatement.java:4400)
    	at hfrps.MainClass.main(MainClass.java:258)
    hOW TO JUST DISPLAY THE
    ERROR MESSAGE

    java.sql.SQLException: ORA-20910: A SCNV_ID COULD NOT BE LOCATED

    And avoid all the subsequent error lines .

    ANYHELP PLS..I NEED TO FINISH THIS PROJECT TODAY ..
    Last edited by renu; 10-08-2010 at 06:49 PM.

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default

    Are you using the printStackTrace() method to generate those lines?
    Look at the Exception class and see if you can get the message from it vs printing out the full stack trace.

  3. #3
    renu is offline Senior Member
    Join Date
    May 2010
    Posts
    117
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    Are you using the printStackTrace() method to generate those lines?
    Look at the Exception class and see if you can get the message from it vs printing out the full stack trace.
    Thank You Norm

    I have used

    System.err.println("java.sql.SQLException: "
    + e.getMessage());

    And this statement prints the first 3 lines

    java.sql.SQLException: ORA-20910: A SCNV_ID COULD NOT BE LOCATED
    ORA-06512: at "SCHOOL.PKG_COMPARE", line 69
    ORA-06512: at line 1

    I only want the first line ....any more help pls

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,559
    Rep Power
    25

    Default

    Get the message into a temp String variable and strip off what you don't want.

  5. #5
    renu is offline Senior Member
    Join Date
    May 2010
    Posts
    117
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    Get the message into a temp String variable and strip off what you don't want.
    Thank You Norm

    String temp = e.getMessage();
    temp = temp.replaceAll(temp, "A SCNV_ID COULD NOT BE LOCATED ..BECAUSE OF WRONG INPUTS");
    System.out.println("ERROR MESSAGE IS :"+temp);

    Thank You ...

  6. #6
    Join Date
    Oct 2010
    Posts
    1
    Rep Power
    0

    Default

    Hi Remember that you are going to get the same error message "ERROR MESSAGE IS :A SCNV_ID COULD NOT BE LOCATED ..BECAUSE OF WRONG INPUTS" for all type of exceptions.

  7. #7
    renu is offline Senior Member
    Join Date
    May 2010
    Posts
    117
    Rep Power
    0

    Default

    Quote Originally Posted by samuelsanthosh@gmail.com View Post
    Hi Remember that you are going to get the same error message "ERROR MESSAGE IS :A SCNV_ID COULD NOT BE LOCATED ..BECAUSE OF WRONG INPUTS" for all type of exceptions.
    Thanks Samuel

    I will fix it .

Similar Threads

  1. Replies: 2
    Last Post: 09-22-2011, 09:48 PM
  2. Error message does not display
    By kaga01 in forum JavaServer Faces (JSF)
    Replies: 1
    Last Post: 12-31-2010, 11:52 AM
  3. Replies: 13
    Last Post: 03-20-2010, 01:03 AM
  4. Display Message Without Throwing Exception
    By kailashchandra in forum JavaServer Faces (JSF)
    Replies: 0
    Last Post: 09-27-2008, 09:05 AM
  5. Display success message in same page when submit button is clicked
    By am17mu in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 03-29-2008, 10:56 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •