You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Bryan Pendleton (JIRA)" <ji...@apache.org> on 2015/07/25 20:50:04 UTC

[jira] [Updated] (DERBY-6803) Change Sqlca and SqlException in NetworkClient to call MessageUtils

     [ https://issues.apache.org/jira/browse/DERBY-6803?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bryan Pendleton updated DERBY-6803:
-----------------------------------
    Attachment: clientOutline.diff

The attached "clientOutline.diff" does not compile and is not
intended to be committed. It is intended to suggest a possible
implementation of this Jira sub-task. The patch assumes the
existence of a method in MessageUtils with the signature:

    Object [] getArgs( String sqlerrmc )

Abhinav, I hope this gives you something concrete to work with
as you continue to study how to build MessageUtils.java.

thanks,

bryan


> Change Sqlca and SqlException in NetworkClient to call MessageUtils
> -------------------------------------------------------------------
>
>                 Key: DERBY-6803
>                 URL: https://issues.apache.org/jira/browse/DERBY-6803
>             Project: Derby
>          Issue Type: Sub-task
>          Components: JDBC, Network Client, Network Server
>            Reporter: Bryan Pendleton
>            Assignee: Abhinav Gupta
>            Priority: Minor
>         Attachments: clientOutline.diff
>
>
> Currently, the network client code is not able to access the arguments
> that are associated with a Derby exception that is returned by the engine.
> We would like to change the network client code, specifically the code
> in the Sqlca and SqlException classes, so that it uses the new MessageUtils
> class to access the exception arguments.
> We wish to take the exception arguments and associate them with the
> SqlException object, so that when the client calls the SQLExceptionFactory
> to create a SQLException to throw to the user application, it can create
> a Derby-specific subclass of that exception, when appropriate, which
> contains the arguments that the server sent to the client.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Re: [jira] [Updated] (DERBY-6803) Change Sqlca and SqlException in NetworkClient to call MessageUtils

Posted by Bryan Pendleton <bp...@gmail.com>.
On 7/25/2015 4:49 PM, Abhinav Gupta wrote:
> Hi Bryan,
>
> I studied your patch and it was helpful. But I still have doubts about the implementation of getArgs() in MessageUtils

Hi Abhinav,

My idea for MessageUtils.getArgs() is that it will do the opposite
of MessageUtils.encodeMessageAndArgumentsAsSqlerrmc().

That is,  MessageUtils.encodeMessageAndArgumentsAsSqlerrmc() takes
a messageId and an Object[]args, and sticks them together into a string.

MessageUtils.getArgs() reverses that process, taking the sqlerrmc string,
and extracting each of the message arguments into a separate String,
which it then puts into an Object [] array and returns.

I think we have already seen the code for this, you can find it
in MessageUtils.getLocalizedMessage, just after the comment:

         // get messageId and arguments, messageId is necessary for us to look up
         // localized message from property file.  messageId was sent as the last
         // token in the sqlerrmc.

So my suggestion is to extract that bit of code from getLocalizedMessage
out into a separate method, called getArgs(), so that we can call
it both from getLocalizedMessage AND from Sqlca.getArgs().

As to the other question you asked, about whether the special
constants such as SQLERRMC_TOKEN_DELIMITER need to be private
in MessageUtils, I don't think that is a requirement.

Eventually, I'd like to see all these details about the encoding and
decoding of message ids and arguments in the sqlerrmc be fully
encapsulated in the MessageUtils class, but we can achieve that
incrementally, over time; we don't have to do that in the first
implementation.

So it's fine in my opinion to leave them public, as you did in your
most recent patch proposal to DERBY-6801.

thanks,

bryan


Re: [jira] [Updated] (DERBY-6803) Change Sqlca and SqlException in NetworkClient to call MessageUtils

Posted by Abhinav Gupta <ab...@gmail.com>.
Hi Bryan,

I studied your patch and it was helpful. But I still have doubts about the
implementation of getArgs() in MessageUtils, in what form will the function
return the arguments ? I've attached the latest MessageUtils class.

On Sun, Jul 26, 2015 at 12:20 AM, Bryan Pendleton (JIRA) <ji...@apache.org>
wrote:

>
>      [
> https://issues.apache.org/jira/browse/DERBY-6803?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
> ]
>
> Bryan Pendleton updated DERBY-6803:
> -----------------------------------
>     Attachment: clientOutline.diff
>
> The attached "clientOutline.diff" does not compile and is not
> intended to be committed. It is intended to suggest a possible
> implementation of this Jira sub-task. The patch assumes the
> existence of a method in MessageUtils with the signature:
>
>     Object [] getArgs( String sqlerrmc )
>
> Abhinav, I hope this gives you something concrete to work with
> as you continue to study how to build MessageUtils.java.
>
> thanks,
>
> bryan
>
>
> > Change Sqlca and SqlException in NetworkClient to call MessageUtils
> > -------------------------------------------------------------------
> >
> >                 Key: DERBY-6803
> >                 URL: https://issues.apache.org/jira/browse/DERBY-6803
> >             Project: Derby
> >          Issue Type: Sub-task
> >          Components: JDBC, Network Client, Network Server
> >            Reporter: Bryan Pendleton
> >            Assignee: Abhinav Gupta
> >            Priority: Minor
> >         Attachments: clientOutline.diff
> >
> >
> > Currently, the network client code is not able to access the arguments
> > that are associated with a Derby exception that is returned by the
> engine.
> > We would like to change the network client code, specifically the code
> > in the Sqlca and SqlException classes, so that it uses the new
> MessageUtils
> > class to access the exception arguments.
> > We wish to take the exception arguments and associate them with the
> > SqlException object, so that when the client calls the
> SQLExceptionFactory
> > to create a SQLException to throw to the user application, it can create
> > a Derby-specific subclass of that exception, when appropriate, which
> > contains the arguments that the server sent to the client.
>
>
>
> --
> This message was sent by Atlassian JIRA
> (v6.3.4#6332)
>