Re: Minor Feature Request - Mailing list pgsql-jdbc

From NielsG
Subject Re: Minor Feature Request
Date
Msg-id 42532102.9070006@aquafold.com
Whole thread Raw
In response to Re: Minor Feature Request  (Oliver Jowett <oliver@opencloud.com>)
List pgsql-jdbc
Hi,

There are two issues that I am trying to solve.  One is for my SQL Query tool which just executes a user defined statement and prints out the SQLException.getMessage() text.  This currently works well, although a Line number in the message for CREATE FUNCTION errors would be nice (Users have asked for this, so they can get the same helpfull message as PGAdmin).  The second issue is that I am building a Procedure/Function editor which displays the error message after a CREATE FUNCTION in a Grid, where the user can double click on the error message and my tool will automatically highlight the line which has the error.  All I really need is the line number, although if it gives me the character position I can easily calculate the line number.

It doesn't really matter to me how I get the line number, whether a "Line X" in the message or a PGException specific class.  The reason is because my tool has specific code for all databases that it supports.  For example, the procedure editor that I am working on gets the line number for Oracle by quering the all_errors table, it gets the line number for SQL Server by parsing the getMessage() text which has the Line number at the beginning of the text, it gets the line number for Sybase Anywhere from the getMessage() text which is at the end of the text and for Sybase it gets it from a SybSQLException class specific with Sybase errors.

So, it doesn't really matter how the line number is presented to me, I already have code to parse it.  And it doesn't matter if it is PostgreSQL specific because I have alot of PG specific code already.

thanks
-Niels



Oliver Jowett wrote:
Kris Jurka wrote: 
On Wed, 6 Apr 2005, Oliver Jowett wrote:

   
Perhaps we should put accessors for the various message parts on
PSQLException, but leave the SQLException message as it currently is.
     
This could work for a pg specific admin tool or client, but not a 
generic/portable java client.   
Right, but aren't we talking about a client that knows about postgresql
internals anyway? There's no concept of line numbers, hints, etc.
associated with an exception in standard JDBC anyway, and as you said
it's not obvious what is useful to have in the error message for
standard clients.

Niels was talking about putting the line number into the message, then
parsing the message to get this info. That seems pretty horrible since
then you have lots of extra work in the app, and the app is still
postgresql-specific.. It seems much cleaner if it can just do something
like:
 try {   // ... } catch (PSQLException e) {   if (e instanceof PSQLException)     linenumber = ((PSQLException)e).getLineNumber();   else     linenumber = -1;
   // handle exception }

-O

 

pgsql-jdbc by date:

Previous
From: Oliver Jowett
Date:
Subject: Re: Minor Feature Request
Next
From: "Anthony Chaffey"
Date:
Subject: An I/O error occured while sending to the backend