This discussion is archived
1 2 3 Previous Next 30 Replies Latest reply: Oct 17, 2012 2:28 AM by rukbat RSS

error handling

Mihael Pro
Currently Being Moderated
If there is an error in query, jdbc throws SQLException. How to find where is the error, i.e. in what column and row ?
  • 1. Re: error handling
    EJP Guru
    Currently Being Moderated
    The error message tells you. Not that all SQL errors relate to a specific row and column.
  • 2. Re: error handling
    gimbal2 Guru
    Currently Being Moderated
    If the DBMS doesn't provide such information, you're not going to find it.

    Debugging a faulty JDBC statement for which it is not apparent what is wrong by staring at the code is to log out the query (and/or inserted values) you execute and then try to invoke that using a DBMS specific management tool, which generally has more debugging capabilities on board.
  • 3. Re: error handling
    Mihael Pro
    Currently Being Moderated
    Sqlplus prints line number and point to the column with '*' :

    SQL> select sysdate
    2 from t1;
    from t1
    *
    ERROR at line 2:
    ORA-00942: table or view does not exist

    Sqldeveloper prints line and column :

    Error at Line: 2 Column: 6

    How to get this info from jdbc ?
  • 4. Re: error handling
    EJP Guru
    Currently Being Moderated
    Sqlplus prints line number and point to the column with '*' :
    That refers to the row and column within the SQLPlus command entry window. There is no command entry window within JDBC. There is just a String that is supposed to contain SQL that you try to convert to a Statement. You get whatever error message the specific JDBC driver gives you if there is something wrong with it. In this specific case you will almost certainly get an SQLException with the message 'ORA-00942: table or view does not exist'. It's not the responsibility of JDBC itself in the slightest. It is 95% interfaces that are implemented by the vendor's driver. In short what you're asking for doesn't really make sense.
  • 5. Re: error handling
    Mihael Pro
    Currently Being Moderated
    You want to say that sqlplus or sqldeveloper has its own sql parser ? Or most likely that SQLException does not have such feature ?
  • 6. Re: error handling
    EJP Guru
    Currently Being Moderated
    You want to say that sqlplus or sqldeveloper has its own sql parser ?
    Obviously.
    Or most likely that SQLException does not have such feature ?
    Of course it doesn't. It's just an exception class. Something in the system has an SQL parser, but it's supplied by the vendor, and it's almost certainly at the server, not in the JDBC driver.
  • 7. Re: error handling
    Mihael Pro
    Currently Being Moderated
    Can it be implemented by standard Oracle jdbc driver ? The same driver is used by Oracle sqldeveloper that has this feature.
  • 8. Re: error handling
    EJP Guru
    Currently Being Moderated
    Can it be implemented by standard Oracle jdbc driver?
    It can be implemented any way the vendor likes as long as he conforms to the JDBC Specification, which is silent on this topic.
    The same driver is used by Oracle sqldeveloper that has this feature.
    Is it? You're assuming that SQL Developer is written in Java, and that it uses a JDBC driver. I don't have any information on the topic, but I see no reason to assume either of those things.
  • 9. Re: error handling
    Mihael Pro
    Currently Being Moderated
    http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html
  • 10. Re: error handling
    rp0428 Guru
    Currently Being Moderated
    >
    Can it be implemented by standard Oracle jdbc driver ? The same driver is used by Oracle sqldeveloper that has this feature.
    >
    The 'driver' has nothing to do with it. Sql developer has other functionality that supports some of the sql*plus features.

    Your original question has already been answered.
    >
    If there is an error in query, jdbc throws SQLException. How to find where is the error, i.e. in what column and row ?
    >
    You can't - queries are parsed and executed on the server, not in the client. It is the server that is throwing the SQL exceptions; the driver only receives it from the server.
  • 11. Re: error handling
    EJP Guru
    Currently Being Moderated
    .It is the server that is throwing the SQL exceptions; the driver only receives it from the server.
    Hardly. The server returns an error code and other information in the proprietary protocol it exchanges with the driver. The driver throws the SQLException. The server would have to be implemented in Java and be communicating via RMI for what you say to be true.
  • 12. Re: error handling
    EJP Guru
    Currently Being Moderated
    Mihael wrote:
    http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html
    I don't know why you are providing me with that link, but there is nothing on that page that contradicts anything I have said here. If you have a point, please state it.
  • 13. Re: error handling
    Mihael Pro
    Currently Being Moderated
    Thanks to all! But the question was - how to get additional parsing error info from server. If sqlplus is written on C and uses full oci functionality, sqldeveloper is written on java and uses the same jdbc drivers.
  • 14. Re: error handling
    EJP Guru
    Currently Being Moderated
    SQLDeveloper is written on java and uses the same jdbc drivers.
    Until you can produce some evidence for that claim it is pointless to just keep repeating it. You also need to tell us what exactly SQL Developer has to do with the topic.
1 2 3 Previous Next

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points