You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Anna Krajewska <am...@gmail.com> on 2012/04/12 11:56:59 UTC
get SQLState from ij.runScript
Hi
Is there an elegant way in which I can get sqlState of the exception
occured while running ij.runScript? I get an output which looks like
command line history, the sqlState is present there but I can only get
it by parsing the string (finding the word "ERROR", then adding 1 for
the empty character and taking whatever is next as sqlState). And if
there isn't - can I assume that the format of the message will always
be like this (line starting with ERROR, whitespace, sqlstate, colon):
ij>my derby instruction
ERROR <SqlState>:
?
I need that because there is no "create or replace view" in derby. I
need to ignore X0Y32 error: object already exists, when I run my
scripts from java.
Regards,
Anna
Re: get SQLState from ij.runScript
Posted by Anna Krajewska <am...@gmail.com>.
That is very helpful, thanks!
Anna
2012/4/12 Rick Hillegas <ri...@oracle.com>:
> On 4/12/12 2:56 AM, Anna Krajewska wrote:
>>
>> Hi
>>
>> Is there an elegant way in which I can get sqlState of the exception
>> occured while running ij.runScript? I get an output which looks like
>> command line history, the sqlState is present there but I can only get
>> it by parsing the string (finding the word "ERROR", then adding 1 for
>> the empty character and taking whatever is next as sqlState). And if
>> there isn't - can I assume that the format of the message will always
>> be like this (line starting with ERROR, whitespace, sqlstate, colon):
>>
>> ij>my derby instruction
>> ERROR<SqlState>:
>>
>> ?
>>
>> I need that because there is no "create or replace view" in derby. I
>> need to ignore X0Y32 error: object already exists, when I run my
>> scripts from java.
>
> Hi Anna,
>
> Sounds like you're running ij under your application and then parsing the
> output. It might be simpler to just parse the sql script into statements and
> run the statements yourself. To do this, you can use the StatementReader
> class attached to https://issues.apache.org/jira/browse/DERBY-5690.
>
> Hope this helps,
> -Rick
>>
>> Regards,
>> Anna
>>
>
Re: get SQLState from ij.runScript
Posted by Rick Hillegas <ri...@oracle.com>.
On 4/12/12 2:56 AM, Anna Krajewska wrote:
> Hi
>
> Is there an elegant way in which I can get sqlState of the exception
> occured while running ij.runScript? I get an output which looks like
> command line history, the sqlState is present there but I can only get
> it by parsing the string (finding the word "ERROR", then adding 1 for
> the empty character and taking whatever is next as sqlState). And if
> there isn't - can I assume that the format of the message will always
> be like this (line starting with ERROR, whitespace, sqlstate, colon):
>
> ij>my derby instruction
> ERROR<SqlState>:
>
> ?
>
> I need that because there is no "create or replace view" in derby. I
> need to ignore X0Y32 error: object already exists, when I run my
> scripts from java.
Hi Anna,
Sounds like you're running ij under your application and then parsing
the output. It might be simpler to just parse the sql script into
statements and run the statements yourself. To do this, you can use the
StatementReader class attached to
https://issues.apache.org/jira/browse/DERBY-5690.
Hope this helps,
-Rick
> Regards,
> Anna
>