NVL function implementation

2010-03-09 Thread Hardie82

Hi,

I want to implement the NVL-function for my derby-db to use sql-statement
once written for an informix-db. Therefor I began to write a function class
with methods like the following code:

  public static String nvl(String arg1, String arg2)
  {
if(arg1 == null)
  return arg2;
return arg1;
  }

I also create a function in sql:

CREATE FUNCTION NVL(arg1 VARCHAR(100), arg2 VARCCHAR(100)) returns
VARCHAR(100) language java 
external name 'mypackage.testdb.DerbyCustomFunctions.nvl' parameter style 
java no sql;

That works fine for statements with varchar-argument and length 100. But
what about other data-types like INTEGER or DATE? Have I to implement
methods for all data-type combination or is there a better way? Something
like a data-type converter for derby? I thought to get informations for
implementation from the nullif-function but can't find it in the derby-code.
-- 
View this message in context: 
http://old.nabble.com/NVL-function-implementation-tp27837153p27837153.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.



Re: Extracting dependencies from SQL statements

2010-03-09 Thread Pavel Bortnovskiy
Thank you, Rick for your expedient response.

Your comments to DERBY-3946 indicate that I need to apply the patch and 
build Derby. Is it possible to avoid? (I am currently using Derby version 
10.5.3.0).

I tried to compile only TreeWalker.java and ASTParser.java while linking 
with Derby's jars, but the build was unsuccessful, as many classes weren't 
found.
Would you be able to advise, please?

Thanks,
Pavel.







Rick Hillegas  
Sent by: richard.hille...@sun.com
03/09/2010 08:35 AM
Please respond to
"Derby Discussion" 


To
Derby Discussion 
cc

Subject
Re: Extracting dependencies from SQL statements






Hi Pavel,

I don't know of an easy way to do this. You could run the statement 
through the Derby parser to get the parsed representation, the Abstract 
Syntax Tree. Then you could write a Visitor to walk the AST, looking for 
the nodes which represent tables. See the following JIRAs for some 
pointers on how to produce and walk the AST: DERBY-3946 and DERBY-791.

Unfortunately, there is no systematic primer on the AST nodes 
themselves. All we have is the javadoc for the package 
org.apache.derby.impl.sql.compile.

Hope this helps,
-Rick

Pavel Bortnovskiy wrote:
>
> Hello:
>
> is it possible to use Derby's SQL parser to "extract" dependencies 
> from a given SQL statement?
> (or access the parser once the statement has been parsed).
>
> Whether it's a simple SELECT or a JOIN, UNION or a more complex 
> statement, I would like to get a list of tables that this statement 
> would depend on.
> Looking for FROM clauses and attempting to do the parsing myself seems 
> like a difficult, error prone and impractical way to approach this.
>
> Any suggestions, please?
>
> Thanks,
> Pavel.
>
>
>
> Jefferies archives and monitors outgoing and incoming e-mail. The 
> contents of this email, including any attachments, are confidential to 
> the ordinary user of the email address to which it was addressed. If 
> you are not the addressee of this email you may not copy, forward, 
> disclose or otherwise use it or any part of it in any form whatsoever. 
> This email may be produced at the request of regulators or in 
> connection with civil litigation. Jefferies accepts no liability for 
> any errors or omissions arising as a result of transmission. Use by 
> other than intended recipients is prohibited.  In the United Kingdom, 
> Jefferies operates as Jefferies International Limited; registered in 
> England: no. 1978621; registered office: Vintners Place, 68 Upper 
> Thames Street, London EC4V 3BJ.  Jefferies International Limited is 
> authorised and regulated by the Financial Services Authority. 







Jefferies archives and monitors outgoing and incoming e-mail. The contents of 
this email, including any attachments, are confidential to the ordinary user of 
the email address to which it was addressed. If you are not the addressee of 
this email you may not copy, forward, disclose or otherwise use it or any part 
of it in any form whatsoever. This email may be produced at the request of 
regulators or in connection with civil litigation. Jefferies accepts no 
liability for any errors or omissions arising as a result of transmission. Use 
by other than intended recipients is prohibited.  In the United Kingdom, 
Jefferies operates as Jefferies International Limited; registered in England: 
no. 1978621; registered office: Vintners Place, 68 Upper Thames Street, London 
EC4V 3BJ.  Jefferies International Limited is authorised and regulated by the 
Financial Services Authority.

Re: NVL function implementation

2010-03-09 Thread Rick Hillegas

Hello,

If you want to do this with a user-defined function, then you will need 
to declare a separate function for each datatype you need to handle.


You might be able to use a CASE expression for this problem. It's a 
little more verbose than using a function. Here is an example:


connect 'jdbc:derby:memory:derby;create=true';

create table t( a int, b int, c date, d date );
insert into t( b, d ) values ( 1, date('1994-02-23') );

select
  case when a is null then b else a end,
  case when c is null then d else c end
from t;

Hope this helps,
-Rick


Hardie82 wrote:

Hi,

I want to implement the NVL-function for my derby-db to use sql-statement
once written for an informix-db. Therefor I began to write a function class
with methods like the following code:

  public static String nvl(String arg1, String arg2)
  {
if(arg1 == null)
  return arg2;
return arg1;
  }

I also create a function in sql:

CREATE FUNCTION NVL(arg1 VARCHAR(100), arg2 VARCCHAR(100)) returns
VARCHAR(100) language java 
external name 'mypackage.testdb.DerbyCustomFunctions.nvl' parameter style 
java no sql;


That works fine for statements with varchar-argument and length 100. But
what about other data-types like INTEGER or DATE? Have I to implement
methods for all data-type combination or is there a better way? Something
like a data-type converter for derby? I thought to get informations for
implementation from the nullif-function but can't find it in the derby-code.
  




Re: NVL function implementation

2010-03-09 Thread Knut Anders Hatlen
Hardie82  writes:

> Hi,
>
> I want to implement the NVL-function for my derby-db to use sql-statement
> once written for an informix-db. Therefor I began to write a function class
> with methods like the following code:
>
>   public static String nvl(String arg1, String arg2)
>   {
> if(arg1 == null)
>   return arg2;
> return arg1;
>   }
>
> I also create a function in sql:
>
> CREATE FUNCTION NVL(arg1 VARCHAR(100), arg2 VARCCHAR(100)) returns
> VARCHAR(100) language java 
> external name 'mypackage.testdb.DerbyCustomFunctions.nvl' parameter style 
> java no sql;
>
> That works fine for statements with varchar-argument and length 100. But
> what about other data-types like INTEGER or DATE? Have I to implement
> methods for all data-type combination or is there a better way? Something
> like a data-type converter for derby? I thought to get informations for
> implementation from the nullif-function but can't find it in the derby-code.

You could use the COALESCE function defined in the SQL standard. It does
more or less the same thing as NVL. See here:
http://db.apache.org/derby/docs/dev/ref/rreffunccoalesce.html

-- 
Knut Anders


Re: Extracting dependencies from SQL statements

2010-03-09 Thread Pavel Bortnovskiy
I was able to compile both files by disabling SanityManager method 
invocation and replacing ContextId.LANG_CONNECTION with its string 
"LanguageConnectionContext". 
No other changes to ASTParser and TreeWalker have been done, however, when 
running them the following exception is thrown:

Parsing:
select a from t, s where t.a = s.a
Exception in thread "main" java.sql.SQLSyntaxErrorException: Table/View 
'T' does not exist.
at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown 
Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at 
org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement.(Unknown Source)
at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement20.(Unknown Source)
at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement30.(Unknown Source)
at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement40.(Unknown Source)
at 
org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Unknown Source)
at 
org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown 
Source)
at TreeWalker.execute(TreeWalker.java:95)
at TreeWalker.main(TreeWalker.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at 
com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)






Rick Hillegas  
Sent by: richard.hille...@sun.com
03/09/2010 08:35 AM
Please respond to
"Derby Discussion" 


To
Derby Discussion 
cc

Subject
Re: Extracting dependencies from SQL statements






Hi Pavel,

I don't know of an easy way to do this. You could run the statement 
through the Derby parser to get the parsed representation, the Abstract 
Syntax Tree. Then you could write a Visitor to walk the AST, looking for 
the nodes which represent tables. See the following JIRAs for some 
pointers on how to produce and walk the AST: DERBY-3946 and DERBY-791.

Unfortunately, there is no systematic primer on the AST nodes 
themselves. All we have is the javadoc for the package 
org.apache.derby.impl.sql.compile.

Hope this helps,
-Rick

Pavel Bortnovskiy wrote:
>
> Hello:
>
> is it possible to use Derby's SQL parser to "extract" dependencies 
> from a given SQL statement?
> (or access the parser once the statement has been parsed).
>
> Whether it's a simple SELECT or a JOIN, UNION or a more complex 
> statement, I would like to get a list of tables that this statement 
> would depend on.
> Looking for FROM clauses and attempting to do the parsing myself seems 
> like a difficult, error prone and impractical way to approach this.
>
> Any suggestions, please?
>
> Thanks,
> Pavel.
>
>
>
> Jefferies archives and monitors outgoing and incoming e-mail. The 
> contents of this email, including any attachments, are confidential to 
> the ordinary user of the email address to which it was addressed. If 
> you are not the addressee of this email you may not copy, forward, 
> disclose or otherwise use it or any part of it in any form whatsoever. 
> This email may be produced at the request of regulators or in 
> connection with civil litigation. Jefferies accepts no liability for 
> any errors or omissions arising as a result of transmission. Use by 
> other than intended recipients is prohibited.  In the United Kingdom, 
> Jefferies operates as Jefferies International Limited; registered in 
> England: no. 1978621; registered office: Vintners Place, 68 Upper 
> Thames Street, London EC4V 3BJ.  Jefferies International Limited is 
> authorised and regulated by the Financial Services Authority. 







Jefferies archives and monitors outgoing and incoming e-mail. The contents of 
this email, including any attachments, are confidential to the ordinary user of 
the email address to which it was addressed. If you are not the addressee of 
this email you may not copy, forward, disclose or otherwise use it or any part 
of it in any form whatsoever. This email may be produced at the request of 
regulators or in connection with civil litigation. Jefferies accepts no 
liability for any errors or omissions arising as a result of transmission. Use 
by other than intended recipients is prohibited.  In the United Kingdom, 
Jefferies operates as Jefferies International Limited; registered in England: 
no. 1978621;

Re: Extracting dependencies from SQL statements

2010-03-09 Thread Rick Hillegas

Hi Pavel,

I don't know of an easy way to do this. You could run the statement 
through the Derby parser to get the parsed representation, the Abstract 
Syntax Tree. Then you could write a Visitor to walk the AST, looking for 
the nodes which represent tables. See the following JIRAs for some 
pointers on how to produce and walk the AST: DERBY-3946 and DERBY-791.


Unfortunately, there is no systematic primer on the AST nodes 
themselves. All we have is the javadoc for the package 
org.apache.derby.impl.sql.compile.


Hope this helps,
-Rick

Pavel Bortnovskiy wrote:


Hello:

is it possible to use Derby's SQL parser to "extract" dependencies 
from a given SQL statement?

(or access the parser once the statement has been parsed).

Whether it's a simple SELECT or a JOIN, UNION or a more complex 
statement, I would like to get a list of tables that this statement 
would depend on.
Looking for FROM clauses and attempting to do the parsing myself seems 
like a difficult, error prone and impractical way to approach this.


Any suggestions, please?

Thanks,
Pavel.



Jefferies archives and monitors outgoing and incoming e-mail. The 
contents of this email, including any attachments, are confidential to 
the ordinary user of the email address to which it was addressed. If 
you are not the addressee of this email you may not copy, forward, 
disclose or otherwise use it or any part of it in any form whatsoever. 
This email may be produced at the request of regulators or in 
connection with civil litigation. Jefferies accepts no liability for 
any errors or omissions arising as a result of transmission. Use by 
other than intended recipients is prohibited.  In the United Kingdom, 
Jefferies operates as Jefferies International Limited; registered in 
England: no. 1978621; registered office: Vintners Place, 68 Upper 
Thames Street, London EC4V 3BJ.  Jefferies International Limited is 
authorised and regulated by the Financial Services Authority. 




JNLP setup creating an apache derby db fails

2010-03-09 Thread Gabriele Kahlout
Hello,

I'm trying to setup a an apache derby db on the users file system
through a setup.jnlp. However, this fails throwing the exception (and
not creating anything) :

Failed to start database 'derbyDB', see the next exception for details.

The same code doesn't break (but works) when executed without java web
start (which from the launch.jnlp a setup.jnlp is first fired).

Looking @ http://db.apache.org/derby/papers/DerbyTut/embedded_intro.html
I get the doubt that it might be that while setup.jnlp is connecting,
also launch.jnlp is from a different JVM, but that sounds non-sense.
But otherwise I don't know what might be the problem, and how to solve
it.

Thanks.

-- 
Regards,
K. Gabriele

--- unchanged since 25/1/10 ---
P.S. Unless a notification (LON), please reply either with an answer
OR with " ACK" appended to this subject within 48 hours. Otherwise, I
might resend.
In(LON, this) ∨ In(48h, TimeNow) ∨ ∃x. In(x, MyInbox) ∧ IsAnswerTo(x,
this) ∨ (In(subject(this), subject(x)) ∧ In(ACK, subject(x)) ∧
¬IsAnswerTo(x,this)) ⇒ ¬IResend(this).

Also note that correspondence may be received only from specified a
priori senders, or if the subject of this email ends with a code, eg.
-LICHT01X, then also from senders whose reply contains it.
∀x. In(x, MyInbox) ⇒ In(senderAddress(x), MySafeSenderList) ∨ (∃y.
In(y, subject(this) ) ∧ In(y,x) ∧ isCodeLike(y, -LICHT01X) ).


Re: Extracting dependencies from SQL statements

2010-03-09 Thread Rick Hillegas

Hi Pavel,

Some comments inline...

Pavel Bortnovskiy wrote:


Thank you, Rick for your expedient response.

Your comments to DERBY-3946 indicate that I need to apply the patch 
and build Derby. Is it possible to avoid? (I am currently using Derby 
version 10.5.3.0).
The initial comment on the issue was confusing. This puzzled someone 
else last month. I have edited that first comment to make it clear that 
the patch was committed a long time ago and was built into both 10.5.1 
and 10.5.3. So there is no need to apply the patch.


I tried to compile only TreeWalker.java and ASTParser.java while 
linking with Derby's jars, but the build was unsuccessful, as many 
classes weren't found.

Would you be able to advise, please?
I am able to compile ASTParser against both the production and debug 
jars. Note that ASTParser must be run against the debug jars. I have 
added this warning to the initial comment on the JIRA.


Could you include the compiler errors you are seeing? That may help us 
diagnose this problem.


Thanks,
-Rick


Thanks,
Pavel.






*Rick Hillegas *
Sent by: richard.hille...@sun.com

03/09/2010 08:35 AM
Please respond to
"Derby Discussion" 



To
Derby Discussion 
cc

Subject
Re: Extracting dependencies from SQL statements









Hi Pavel,

I don't know of an easy way to do this. You could run the statement
through the Derby parser to get the parsed representation, the Abstract
Syntax Tree. Then you could write a Visitor to walk the AST, looking for
the nodes which represent tables. See the following JIRAs for some
pointers on how to produce and walk the AST: DERBY-3946 and DERBY-791.

Unfortunately, there is no systematic primer on the AST nodes
themselves. All we have is the javadoc for the package
org.apache.derby.impl.sql.compile.

Hope this helps,
-Rick

Pavel Bortnovskiy wrote:
>
> Hello:
>
> is it possible to use Derby's SQL parser to "extract" dependencies
> from a given SQL statement?
> (or access the parser once the statement has been parsed).
>
> Whether it's a simple SELECT or a JOIN, UNION or a more complex
> statement, I would like to get a list of tables that this statement
> would depend on.
> Looking for FROM clauses and attempting to do the parsing myself seems
> like a difficult, error prone and impractical way to approach this.
>
> Any suggestions, please?
>
> Thanks,
> Pavel.
>
>
>
> Jefferies archives and monitors outgoing and incoming e-mail. The
> contents of this email, including any attachments, are confidential to
> the ordinary user of the email address to which it was addressed. If
> you are not the addressee of this email you may not copy, forward,
> disclose or otherwise use it or any part of it in any form whatsoever.
> This email may be produced at the request of regulators or in
> connection with civil litigation. Jefferies accepts no liability for
> any errors or omissions arising as a result of transmission. Use by
> other than intended recipients is prohibited.  In the United Kingdom,
> Jefferies operates as Jefferies International Limited; registered in
> England: no. 1978621; registered office: Vintners Place, 68 Upper
> Thames Street, London EC4V 3BJ.  Jefferies International Limited is
> authorised and regulated by the Financial Services Authority.






Jefferies archives and monitors outgoing and incoming e-mail. The 
contents of this email, including any attachments, are confidential to 
the ordinary user of the email address to which it was addressed. If 
you are not the addressee of this email you may not copy, forward, 
disclose or otherwise use it or any part of it in any form whatsoever. 
This email may be produced at the request of regulators or in 
connection with civil litigation. Jefferies accepts no liability for 
any errors or omissions arising as a result of transmission. Use by 
other than intended recipients is prohibited.  In the United Kingdom, 
Jefferies operates as Jefferies International Limited; registered in 
England: no. 1978621; registered office: Vintners Place, 68 Upper 
Thames Street, London EC4V 3BJ.  Jefferies International Limited is 
authorised and regulated by the Financial Services Authority. 




Re: JNLP setup creating an apache derby db fails

2010-03-09 Thread Knut Anders Hatlen
Gabriele Kahlout  writes:

> Hello,
>
> I'm trying to setup a an apache derby db on the users file system
> through a setup.jnlp. However, this fails throwing the exception (and
> not creating anything) :
>
> Failed to start database 'derbyDB', see the next exception for details.

What does the next exception say? You can find it either in derby.log or
by using the technique described on this wiki page:
http://wiki.apache.org/db-derby/UnwindExceptionChain

-- 
Knut Anders


Re: Extracting dependencies from SQL statements

2010-03-09 Thread Rick Hillegas

Hi Pavel,

These programs should be run using the Derby debug jars. I have edited 
the introductory comment to try to make this clear. The debug logic must 
be compiled into Derby in order for compilation to stop after parsing. 
If you need a solution which runs against the production jars, take a 
look at the related issue DERBY-791.


Hope this helps,
-Rick

Pavel Bortnovskiy wrote:


I was able to compile both files by disabling SanityManager method 
invocation and replacing ContextId.LANG_CONNECTION with its string 
"LanguageConnectionContext".
No other changes to ASTParser and TreeWalker have been done, however, 
when running them the following exception is thrown:


Parsing:
select a from t, s where t.a = s.a
Exception in thread "main" java.sql.SQLSyntaxErrorException: 
Table/View 'T' does not exist.
at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement.(Unknown Source)
at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement20.(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement30.(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement40.(Unknown 
Source)
at 
org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Unknown Source)
at 
org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown 
Source)

at TreeWalker.execute(TreeWalker.java:95)
at TreeWalker.main(TreeWalker.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 

at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 


at java.lang.reflect.Method.invoke(Method.java:597)
at 
com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)






*Rick Hillegas *
Sent by: richard.hille...@sun.com

03/09/2010 08:35 AM
Please respond to
"Derby Discussion" 



To
Derby Discussion 
cc

Subject
Re: Extracting dependencies from SQL statements









Hi Pavel,

I don't know of an easy way to do this. You could run the statement
through the Derby parser to get the parsed representation, the Abstract
Syntax Tree. Then you could write a Visitor to walk the AST, looking for
the nodes which represent tables. See the following JIRAs for some
pointers on how to produce and walk the AST: DERBY-3946 and DERBY-791.

Unfortunately, there is no systematic primer on the AST nodes
themselves. All we have is the javadoc for the package
org.apache.derby.impl.sql.compile.

Hope this helps,
-Rick

Pavel Bortnovskiy wrote:
>
> Hello:
>
> is it possible to use Derby's SQL parser to "extract" dependencies
> from a given SQL statement?
> (or access the parser once the statement has been parsed).
>
> Whether it's a simple SELECT or a JOIN, UNION or a more complex
> statement, I would like to get a list of tables that this statement
> would depend on.
> Looking for FROM clauses and attempting to do the parsing myself seems
> like a difficult, error prone and impractical way to approach this.
>
> Any suggestions, please?
>
> Thanks,
> Pavel.
>
>
>
> Jefferies archives and monitors outgoing and incoming e-mail. The
> contents of this email, including any attachments, are confidential to
> the ordinary user of the email address to which it was addressed. If
> you are not the addressee of this email you may not copy, forward,
> disclose or otherwise use it or any part of it in any form whatsoever.
> This email may be produced at the request of regulators or in
> connection with civil litigation. Jefferies accepts no liability for
> any errors or omissions arising as a result of transmission. Use by
> other than intended recipients is prohibited.  In the United Kingdom,
> Jefferies operates as Jefferies International Limited; registered in
> England: no. 1978621; registered office: Vintners Place, 68 Upper
> Thames Street, London EC4V 3BJ.  Jefferies International Limited is
> authorised and regulated by the Financial Services Authority.






Jefferies archives and monitors outgoing and incoming e-mail. The 
contents of this email, including any attachments, are confidential to 
the ordinary user of the email address to which it was addressed. If 
you are not the addressee of this email you may not copy, forward, 
disclose or

Re: Extracting dependencies from SQL statements

2010-03-09 Thread Pavel Bortnovskiy
Once again, Rick, thanks for your prompt response. To answer your 
questions:

(1) The compilation errors initially had to do with the SanityManager and 
ContextId not available in prod jars.

(2) Since I am trying to get this code to work in our application, using 
debug jars may not be desirable.
More over, our app is using Derby's in-memory tables as well as its 
NetworkServerController.
So, this parsing/tree-walking code should not conflict with the other two 
uses.

In the comments for DERBY-791, I did notice "We should provide some 
mechanism for printing these trees in production (non-debug) servers".
So, I ran XmlTreeWalker linking only to 
db-derby-10.5.3.0-bin/lib/derby.jar, but got the same exception:



select a from t, s where t.a = s.a
Exception in thread "main" java.sql.SQLSyntaxErrorException: Table/View 
'T' does not exist.
at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown 
Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at 
org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement.(Unknown Source)
at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement20.(Unknown Source)
at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement30.(Unknown Source)
at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement40.(Unknown Source)
at 
org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Unknown Source)
at 
org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown 
Source)
at XmlTreeWalker.execute(XmlTreeWalker.java:130)
at XmlTreeWalker.main(XmlTreeWalker.java:111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at 
com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)
Caused by: java.sql.SQLException: Table/View 'T' does not exist.
at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
 
Source)
... 20 more
Caused by: ERROR 42X05: Table/View 'T' does not exist.
at 
org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at 
org.apache.derby.impl.sql.compile.FromBaseTable.bindTableDescriptor(Unknown 
Source)
at 
org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(Unknown 
Source)
at org.apache.derby.impl.sql.compile.FromList.bindTables(Unknown 
Source)
at 
org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(Unknown 
Source)
at 
org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(Unknown 
Source)
at org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown 
Source)
at 
org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown 
Source)
at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown 
Source)
at 
org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown
 
Source)
... 14 more

Regards,
Pavel.






Rick Hillegas  
Sent by: richard.hille...@sun.com
03/09/2010 11:22 AM
Please respond to
"Derby Discussion" 


To
Derby Discussion 
cc

Subject
Re: Extracting dependencies from SQL statements






Hi Pavel,

These programs should be run using the Derby debug jars. I have edited 
the introductory comment to try to make this clear. The debug logic must 
be compiled into Derby in order for compilation to stop after parsing. 
If you need a solution which runs against the production jars, take a 
look at the related issue DERBY-791.

Hope this helps,
-Rick

Pavel Bortnovskiy wrote:
>
> I was able to compile both files by disabling SanityManager method 
> invocation and replacing ContextId.LANG_CONNECTION with its string 
> "LanguageConnectionContext".
> No other changes to ASTParser and TreeWalker have been done, however, 
> when running them the following exception is thrown:
>
> Parsing:
> select a from t, s where t.a = s.a
> Exception in thread "main" java.sql.SQLSyntaxErrorException: 
> Table/View 'T' does not exist.
> at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown 

Re: JNLP setup creating an apache derby db fails - versuchen01X

2010-03-09 Thread Gabriele Kahlout
Here is only the trace:

the most telling line should be (but I don't know what it means, and
how to solve it):

Caused by: java.sql.SQLException: Java exception: 'access denied
(java.io.FilePermission
/Users/simpatico/archive/db.sqlwrapper/service.properties read):
java.security.AccessControlException'.




java.sql.SQLException: Failed to start database
'/Users/simpatico/archive/db.sqlwrapper', see the next exception for
details.
at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.seeNextException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.bootDatabase(Unknown 
Source)
at org.apache.derby.impl.jdbc.EmbedConnection.(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection30.(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection40.(Unknown Source)
at org.apache.derby.jdbc.Driver40.getNewEmbedConnection(Unknown Source)
at org.apache.derby.jdbc.InternalDriver.connect(Unknown Source)
at org.apache.derby.jdbc.AutoloadedDriver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:207)
at 
com.mysimpatico.sqlwrapper.database.SqlWrapper.connectToDerby(SqlWrapper.java:154)
at com.mysimpatico.memorizeasy.engine.Database.init(Unknown Source)
at com.mysimpatico.memorizeasy.engine.Database.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.javaws.Launcher.executeApplication(Launcher.java:1528)
at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1466)
at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:1277)
at com.sun.javaws.Launcher.run(Launcher.java:117)
at java.lang.Thread.run(Thread.java:637)
Caused by: java.sql.SQLException: Failed to start database
'/Users/simpatico/archive/db.sqlwrapper', see the next exception for
details.
at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
Source)
at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
Source)
... 24 more
Caused by: java.sql.SQLException: Java exception: 'access denied
(java.io.FilePermission
/Users/simpatico/archive/db.sqlwrapper/service.properties read):
java.security.AccessControlException'.
at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
Source)
at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
Source)
at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source)
... 21 more
Caused by: java.security.AccessControlException: access denied
(java.io.FilePermission
/Users/simpatico/archive/db.sqlwrapper/service.properties read)
at 
java.security.AccessControlContext.checkPermission(AccessControlContext.java:323)
at 
java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at java.lang.SecurityManager.checkRead(SecurityManager.java:871)
at java.io.FileInputStream.(FileInputStream.java:100)
at org.apache.derby.impl.io.DirFile.getInputStream(Unknown Source)
at 
org.apache.derby.impl.services.monitor.StorageFactoryService$4.run(Unknown
Source)
at java.security.AccessController.doPrivileged(Native Method)
at 
org.apache.derby.impl.services.monitor.StorageFactoryService.getServiceProperties(Unknown
Source)
at 
org.apache.derby.impl.services.monitor.BaseMonitor.findProviderAndStartService(Unknown
Source)
at 
org.apache.derby.impl.services.monitor.BaseMonitor.startPersistentService(Unknown
Source)
at 
org.apache.derby.iapi.services.monitor.Monitor.startPersistentService(Unknown
Source)
... 21 more
= begin nested exception, level (1) ===
java.sql.SQLException: Java exception: 'access denied
(java.io.FilePermission
/Users/simpatico/archive/db.sqlwrapper/service.properties read):
java.security.AccessControlException'.
at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
Source)
at org.apache.derby.impl.jdbc.Util.newEmbedSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.javaException(Unknown Source)
at org.apache.derby.impl.

Re: JNLP setup creating an apache derby db fails - versuchen01X

2010-03-09 Thread Knut Anders Hatlen
Gabriele Kahlout  writes:

> Here is only the trace:
>
> the most telling line should be (but I don't know what it means, and
> how to solve it):
>
> Caused by: java.sql.SQLException: Java exception: 'access denied
> (java.io.FilePermission
> /Users/simpatico/archive/db.sqlwrapper/service.properties read):
> java.security.AccessControlException'.

It looks like Java Web Start runs the application with a security
manager that prevents you from reading the database, so you'll probably
need to grant some permissions to derby.jar. I don't know how to do that
in a Java Web Start environment myself, but perhaps someone else does
and will chime in...

-- 
Knut Anders


Re: JNLP setup creating an apache derby db fails - versuchen01X

2010-03-09 Thread Gabriele Kahlout
is there a link to this email conv, so that I post it to
http://forums.sun.com/thread.jspa?messageID=10947198� ?

2010/3/9, Knut Anders Hatlen :
> Gabriele Kahlout  writes:
>
>> Here is only the trace:
>>
>> the most telling line should be (but I don't know what it means, and
>> how to solve it):
>>
>> Caused by: java.sql.SQLException: Java exception: 'access denied
>> (java.io.FilePermission
>> /Users/simpatico/archive/db.sqlwrapper/service.properties read):
>> java.security.AccessControlException'.
>
> It looks like Java Web Start runs the application with a security
> manager that prevents you from reading the database, so you'll probably
> need to grant some permissions to derby.jar. I don't know how to do that
> in a Java Web Start environment myself, but perhaps someone else does
> and will chime in...
>
> --
> Knut Anders
>


-- 
Regards,
K. Gabriele

--- unchanged since 25/1/10 ---
P.S. Unless a notification (LON), please reply either with an answer
OR with " ACK" appended to this subject within 48 hours. Otherwise, I
might resend.
In(LON, this) ∨ In(48h, TimeNow) ∨ ∃x. In(x, MyInbox) ∧ IsAnswerTo(x,
this) ∨ (In(subject(this), subject(x)) ∧ In(ACK, subject(x)) ∧
¬IsAnswerTo(x,this)) ⇒ ¬IResend(this).

Also note that correspondence may be received only from specified a
priori senders, or if the subject of this email ends with a code, eg.
-LICHT01X, then also from senders whose reply contains it.
∀x. In(x, MyInbox) ⇒ In(senderAddress(x), MySafeSenderList) ∨ (∃y.
In(y, subject(this) ) ∧ In(y,x) ∧ isCodeLike(y, -LICHT01X) ).


Re: JNLP setup creating an apache derby db fails - versuchen01X

2010-03-09 Thread Lance Andersen
My old blog might help
http://weblogs.java.net/blog/2007/06/15/using-java-web-start-java-persistence-api

-lance
On Mar 9, 2010, at 12:15 PM, Knut Anders Hatlen wrote:

> Gabriele Kahlout  writes:
> 
>> Here is only the trace:
>> 
>> the most telling line should be (but I don't know what it means, and
>> how to solve it):
>> 
>> Caused by: java.sql.SQLException: Java exception: 'access denied
>> (java.io.FilePermission
>> /Users/simpatico/archive/db.sqlwrapper/service.properties read):
>> java.security.AccessControlException'.
> 
> It looks like Java Web Start runs the application with a security
> manager that prevents you from reading the database, so you'll probably
> need to grant some permissions to derby.jar. I don't know how to do that
> in a Java Web Start environment myself, but perhaps someone else does
> and will chime in...
> 
> -- 
> Knut Anders



Re: Extracting dependencies from SQL statements

2010-03-09 Thread Rick Hillegas

Hi Pavel,

You are right, the XmlTreeWalker class also tries to stop the compiler 
after parsing. This can only be done with a debug engine. The error you 
are seeing comes from the bind() phase of compilation. Derby is 
complaining that the query doesn't make sense: the objects it mentions 
don't exist.


There's another issue linked from the XmlTreeWalker issue. Take a look 
at DERBY-4415. This is a slightly more involved solution but may get you 
closer. This solution assumes that you are trying to examine the various 
phases of the AST for a query against real objects in your database. 
This should work with the production jars.


Hope this is more useful,
-Rick

Pavel Bortnovskiy wrote:


Once again, Rick, thanks for your prompt response. To answer your 
questions:


(1) The compilation errors initially had to do with the SanityManager 
and ContextId not available in prod jars.


(2) Since I am trying to get this code to work in our application, 
using debug jars may not be desirable.
More over, our app is using Derby's in-memory tables as well as its 
NetworkServerController.
So, this parsing/tree-walking code should not conflict with the other 
two uses.


In the comments for DERBY-791, I did notice "We should provide some 
mechanism for printing these trees in production (non-debug) servers".
So, I ran XmlTreeWalker linking only to 
db-derby-10.5.3.0-bin/lib/derby.jar, but got the same exception:




select a from t, s where t.a = s.a
Exception in thread "main" java.sql.SQLSyntaxErrorException: 
Table/View 'T' does not exist.
at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement.(Unknown Source)
at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement20.(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement30.(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.EmbedPreparedStatement40.(Unknown 
Source)
at 
org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Unknown Source)
at 
org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown 
Source)

at XmlTreeWalker.execute(XmlTreeWalker.java:130)
at XmlTreeWalker.main(XmlTreeWalker.java:111)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 

at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 


at java.lang.reflect.Method.invoke(Method.java:597)
at 
com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)

Caused by: java.sql.SQLException: Table/View 'T' does not exist.
at 
org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown 
Source)
at 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown 
Source)

... 20 more
Caused by: ERROR 42X05: Table/View 'T' does not exist.
at 
org.apache.derby.iapi.error.StandardException.newException(Unknown 
Source)
at 
org.apache.derby.impl.sql.compile.FromBaseTable.bindTableDescriptor(Unknown 
Source)
at 
org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(Unknown 
Source)
at 
org.apache.derby.impl.sql.compile.FromList.bindTables(Unknown Source)
at 
org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(Unknown 
Source)
at 
org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(Unknown 
Source)
at 
org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown Source)
at 
org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown 
Source)
at 
org.apache.derby.impl.sql.GenericStatement.prepMinion(Unknown Source)
at org.apache.derby.impl.sql.GenericStatement.prepare(Unknown 
Source)
at 
org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(Unknown 
Source)

... 14 more

Regards,
Pavel.





*Rick Hillegas *
Sent by: richard.hille...@sun.com

03/09/2010 11:22 AM
Please respond to
"Derby Discussion" 



To
Derby Discussion 
cc

Subject
Re: Extracting dependencies from SQL statements









Hi Pavel,

These programs should be run using the Derby debug jars. I have edited
the introductory comment to try to make this clear. The debug logic must
be 

Re: Extracting dependencies from SQL statements

2010-03-09 Thread Pavel Bortnovskiy
Rick (while I am reading  and trying DERBY-4415), that seems like there is 
no other way to use prod jars and yet stop the parser from binding?

Would it be at all possible to use the javacc compiler with sqlgrammar.jj 
(that are probably bundled in derby.jar) to do the work?

Pavel.






Rick Hillegas  
Sent by: richard.hille...@sun.com
03/09/2010 01:13 PM
Please respond to
"Derby Discussion" 


To
Derby Discussion 
cc

Subject
Re: Extracting dependencies from SQL statements






Hi Pavel,

You are right, the XmlTreeWalker class also tries to stop the compiler 
after parsing. This can only be done with a debug engine. The error you 
are seeing comes from the bind() phase of compilation. Derby is 
complaining that the query doesn't make sense: the objects it mentions 
don't exist.

There's another issue linked from the XmlTreeWalker issue. Take a look 
at DERBY-4415. This is a slightly more involved solution but may get you 
closer. This solution assumes that you are trying to examine the various 
phases of the AST for a query against real objects in your database. 
This should work with the production jars.

Hope this is more useful,
-Rick

Pavel Bortnovskiy wrote:
>
> Once again, Rick, thanks for your prompt response. To answer your 
> questions:
>
> (1) The compilation errors initially had to do with the SanityManager 
> and ContextId not available in prod jars.
>
> (2) Since I am trying to get this code to work in our application, 
> using debug jars may not be desirable.
> More over, our app is using Derby's in-memory tables as well as its 
> NetworkServerController.
> So, this parsing/tree-walking code should not conflict with the other 
> two uses.
>
> In the comments for DERBY-791, I did notice "We should provide some 
> mechanism for printing these trees in production (non-debug) servers".
> So, I ran XmlTreeWalker linking only to 
> db-derby-10.5.3.0-bin/lib/derby.jar, but got the same exception:
>
> 
> 
> select a from t, s where t.a = s.a
> Exception in thread "main" java.sql.SQLSyntaxErrorException: 
> Table/View 'T' does not exist.
> at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown 

> Source)
> at 
> org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
> at 
> 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown 

> Source)
> at 
> 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown 

> Source)
> at 
> org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown 
> Source)
> at 
> org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown 
> Source)
> at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement.(Unknown Source)
> at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement20.(Unknown 
> Source)
> at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement30.(Unknown 
> Source)
> at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement40.(Unknown 
> Source)
> at 
> org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Unknown Source)
> at 
> org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown 
> Source)
> at 
> org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown 
> Source)
> at XmlTreeWalker.execute(XmlTreeWalker.java:130)
> at XmlTreeWalker.main(XmlTreeWalker.java:111)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 

>
> at 
> 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 

>
> at java.lang.reflect.Method.invoke(Method.java:597)
> at 
> com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)
> Caused by: java.sql.SQLException: Table/View 'T' does not exist.
> at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown 
> Source)
> at 
> 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
 

> Source)
> ... 20 more
> Caused by: ERROR 42X05: Table/View 'T' does not exist.
> at 
> org.apache.derby.iapi.error.StandardException.newException(Unknown 
> Source)
> at 
> 
org.apache.derby.impl.sql.compile.FromBaseTable.bindTableDescriptor(Unknown 

> Source)
> at 
> org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(Unknown 

> Source)
> at 
> org.apache.derby.impl.sql.compile.FromList.bindTables(Unknown Source)
> at 
> org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(Unknown 
> Source)
> at 
> org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(Unknown 
> Source)
> at 
> org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown Source)
> at 
> org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown 
> Source)
> at 
> org.apache.derby

Re: JNLP setup creating an apache derby db fails - versuchen01X

2010-03-09 Thread Gabriele Kahlout
I solved it, by adding the setSecurityManager(null). However the app
still crashes. How do I debug java web start apps (in non web start
mode everything runs smoothly). It's in run-time jws that it crashes,
and the java console closes before i can see the exceptions. I don't
know how could I debug?

2010/3/9, Lance Andersen :
> My old blog might help
> http://weblogs.java.net/blog/2007/06/15/using-java-web-start-java-persistence-api
>
> -lance
> On Mar 9, 2010, at 12:15 PM, Knut Anders Hatlen wrote:
>
>> Gabriele Kahlout  writes:
>>
>>> Here is only the trace:
>>>
>>> the most telling line should be (but I don't know what it means, and
>>> how to solve it):
>>>
>>> Caused by: java.sql.SQLException: Java exception: 'access denied
>>> (java.io.FilePermission
>>> /Users/simpatico/archive/db.sqlwrapper/service.properties read):
>>> java.security.AccessControlException'.
>>
>> It looks like Java Web Start runs the application with a security
>> manager that prevents you from reading the database, so you'll probably
>> need to grant some permissions to derby.jar. I don't know how to do that
>> in a Java Web Start environment myself, but perhaps someone else does
>> and will chime in...
>>
>> --
>> Knut Anders
>
>


-- 
Regards,
K. Gabriele

--- unchanged since 25/1/10 ---
P.S. Unless a notification (LON), please reply either with an answer
OR with " ACK" appended to this subject within 48 hours. Otherwise, I
might resend.
In(LON, this) ∨ In(48h, TimeNow) ∨ ∃x. In(x, MyInbox) ∧ IsAnswerTo(x,
this) ∨ (In(subject(this), subject(x)) ∧ In(ACK, subject(x)) ∧
¬IsAnswerTo(x,this)) ⇒ ¬IResend(this).

Also note that correspondence may be received only from specified a
priori senders, or if the subject of this email ends with a code, eg.
-LICHT01X, then also from senders whose reply contains it.
∀x. In(x, MyInbox) ⇒ In(senderAddress(x), MySafeSenderList) ∨ (∃y.
In(y, subject(this) ) ∧ In(y,x) ∧ isCodeLike(y, -LICHT01X) ).


Re: Extracting dependencies from SQL statements

2010-03-09 Thread Pavel Bortnovskiy
Rick:

ASTVisitor (used in public class XmlASTPrinter implements ASTVisitor) is 
nowhere to be found: import org.apache.derby.iapi.sql.compile.ASTVisitor;

It is neither in the src tree nor in the JIRA DERBY-4415. Can you please 
advise?

Thanks,
Pavel.






Rick Hillegas  
Sent by: richard.hille...@sun.com
03/09/2010 01:13 PM
Please respond to
"Derby Discussion" 


To
Derby Discussion 
cc

Subject
Re: Extracting dependencies from SQL statements






Hi Pavel,

You are right, the XmlTreeWalker class also tries to stop the compiler 
after parsing. This can only be done with a debug engine. The error you 
are seeing comes from the bind() phase of compilation. Derby is 
complaining that the query doesn't make sense: the objects it mentions 
don't exist.

There's another issue linked from the XmlTreeWalker issue. Take a look 
at DERBY-4415. This is a slightly more involved solution but may get you 
closer. This solution assumes that you are trying to examine the various 
phases of the AST for a query against real objects in your database. 
This should work with the production jars.

Hope this is more useful,
-Rick

Pavel Bortnovskiy wrote:
>
> Once again, Rick, thanks for your prompt response. To answer your 
> questions:
>
> (1) The compilation errors initially had to do with the SanityManager 
> and ContextId not available in prod jars.
>
> (2) Since I am trying to get this code to work in our application, 
> using debug jars may not be desirable.
> More over, our app is using Derby's in-memory tables as well as its 
> NetworkServerController.
> So, this parsing/tree-walking code should not conflict with the other 
> two uses.
>
> In the comments for DERBY-791, I did notice "We should provide some 
> mechanism for printing these trees in production (non-debug) servers".
> So, I ran XmlTreeWalker linking only to 
> db-derby-10.5.3.0-bin/lib/derby.jar, but got the same exception:
>
> 
> 
> select a from t, s where t.a = s.a
> Exception in thread "main" java.sql.SQLSyntaxErrorException: 
> Table/View 'T' does not exist.
> at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown 

> Source)
> at 
> org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
> at 
> 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown 

> Source)
> at 
> 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown 

> Source)
> at 
> org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown 
> Source)
> at 
> org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown 
> Source)
> at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement.(Unknown Source)
> at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement20.(Unknown 
> Source)
> at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement30.(Unknown 
> Source)
> at 
> org.apache.derby.impl.jdbc.EmbedPreparedStatement40.(Unknown 
> Source)
> at 
> org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Unknown Source)
> at 
> org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown 
> Source)
> at 
> org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown 
> Source)
> at XmlTreeWalker.execute(XmlTreeWalker.java:130)
> at XmlTreeWalker.main(XmlTreeWalker.java:111)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at 
> 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 

>
> at 
> 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 

>
> at java.lang.reflect.Method.invoke(Method.java:597)
> at 
> com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)
> Caused by: java.sql.SQLException: Table/View 'T' does not exist.
> at 
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown 
> Source)
> at 
> 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown
 

> Source)
> ... 20 more
> Caused by: ERROR 42X05: Table/View 'T' does not exist.
> at 
> org.apache.derby.iapi.error.StandardException.newException(Unknown 
> Source)
> at 
> 
org.apache.derby.impl.sql.compile.FromBaseTable.bindTableDescriptor(Unknown 

> Source)
> at 
> org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(Unknown 

> Source)
> at 
> org.apache.derby.impl.sql.compile.FromList.bindTables(Unknown Source)
> at 
> org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(Unknown 
> Source)
> at 
> org.apache.derby.impl.sql.compile.DMLStatementNode.bindTables(Unknown 
> Source)
> at 
> org.apache.derby.impl.sql.compile.DMLStatementNode.bind(Unknown Source)
> at 
> org.apache.derby.impl.sql.compile.CursorNode.bindStatement(Unknown 
> Source)
> at 
> org.apache.derby.impl.sql.GenericStatement.prep

Re: Extracting dependencies from SQL statements

2010-03-09 Thread Rick Hillegas

Hi Pavel,

This approach is only possible in the development trunk right now. It 
will turn up in 10.6. To experiment with this approach, you will need to 
set up a subversion client and build the development trunk.


Hope this helps,
-Rick

Pavel Bortnovskiy wrote:


Rick:

ASTVisitor (used in public class XmlASTPrinter implements ASTVisitor) 
is nowhere to be found: import 
org.apache.derby.iapi.sql.compile.ASTVisitor;


It is neither in the src tree nor in the JIRA DERBY-4415. Can you 
please advise?


Thanks,
Pavel.





*Rick Hillegas *
Sent by: richard.hille...@sun.com

03/09/2010 01:13 PM
Please respond to
"Derby Discussion" 



To
Derby Discussion 
cc

Subject
Re: Extracting dependencies from SQL statements









Hi Pavel,

You are right, the XmlTreeWalker class also tries to stop the compiler
after parsing. This can only be done with a debug engine. The error you
are seeing comes from the bind() phase of compilation. Derby is
complaining that the query doesn't make sense: the objects it mentions
don't exist.

There's another issue linked from the XmlTreeWalker issue. Take a look
at DERBY-4415. This is a slightly more involved solution but may get you
closer. This solution assumes that you are trying to examine the various
phases of the AST for a query against real objects in your database.
This should work with the production jars.

Hope this is more useful,
-Rick

Pavel Bortnovskiy wrote:
>
> Once again, Rick, thanks for your prompt response. To answer your
> questions:
>
> (1) The compilation errors initially had to do with the SanityManager
> and ContextId not available in prod jars.
>
> (2) Since I am trying to get this code to work in our application,
> using debug jars may not be desirable.
> More over, our app is using Derby's in-memory tables as well as its
> NetworkServerController.
> So, this parsing/tree-walking code should not conflict with the other
> two uses.
>
> In the comments for DERBY-791, I did notice "We should provide some
> mechanism for printing these trees in production (non-debug) servers".
> So, I ran XmlTreeWalker linking only to
> db-derby-10.5.3.0-bin/lib/derby.jar, but got the same exception:
>
> 
> 
> select a from t, s where t.a = s.a
> Exception in thread "main" java.sql.SQLSyntaxErrorException:
> Table/View 'T' does not exist.
> at
> 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown

> Source)
> at
> org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
> at
> 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown 


> Source)
> at
> 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown 


> Source)
> at
> org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown
> Source)
> at
> org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown
> Source)
> at
> org.apache.derby.impl.jdbc.EmbedPreparedStatement.(Unknown Source)
> at
> org.apache.derby.impl.jdbc.EmbedPreparedStatement20.(Unknown
> Source)
> at
> org.apache.derby.impl.jdbc.EmbedPreparedStatement30.(Unknown
> Source)
> at
> org.apache.derby.impl.jdbc.EmbedPreparedStatement40.(Unknown
> Source)
> at
> org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Unknown Source)
> at
> org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown
> Source)
> at
> org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown
> Source)
> at XmlTreeWalker.execute(XmlTreeWalker.java:130)
> at XmlTreeWalker.main(XmlTreeWalker.java:111)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 


>
> at
> 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 


>
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)
> Caused by: java.sql.SQLException: Table/View 'T' does not exist.
> at
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
> Source)
> at
> 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown 


> Source)
> ... 20 more
> Caused by: ERROR 42X05: Table/View 'T' does not exist.
> at
> org.apache.derby.iapi.error.StandardException.newException(Unknown
> Source)
> at
> 
org.apache.derby.impl.sql.compile.FromBaseTable.bindTableDescriptor(Unknown 


> Source)
> at
> 
org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(Unknown

> Source)
> at
> org.apache.derby.impl.sql.compile.FromList.bindTables(Unknown Source)
> at
> org.apache.derby.impl.sql.compile.SelectNode.bindNonVTITables(Unknown
> Source)
> at
> org.apache.derby.impl.sql.compile.DMLStatementNode.bin

Re: Extracting dependencies from SQL statements

2010-03-09 Thread Rick Hillegas

Hi Pavel,

Some comments inline...

Pavel Bortnovskiy wrote:


Rick (while I am reading  and trying DERBY-4415), that seems like 
there is no other way to use prod jars and yet stop the parser from 
binding?


It looks to me as though the shortcircuiting logic is guarded by a check 
for whether the engine is the debug version.


Would it be at all possible to use the javacc compiler with 
sqlgrammar.jj (that are probably bundled in derby.jar) to do the work?
I think you will discover that the grammar relies on a fair amount of 
session context supplied by the rest of the Derby SQL interpreter. I 
think you will be frustrated very quickly if you try this approach.


Hope this helps,
-Rick


Pavel.





*Rick Hillegas *
Sent by: richard.hille...@sun.com

03/09/2010 01:13 PM
Please respond to
"Derby Discussion" 



To
Derby Discussion 
cc

Subject
Re: Extracting dependencies from SQL statements









Hi Pavel,

You are right, the XmlTreeWalker class also tries to stop the compiler
after parsing. This can only be done with a debug engine. The error you
are seeing comes from the bind() phase of compilation. Derby is
complaining that the query doesn't make sense: the objects it mentions
don't exist.

There's another issue linked from the XmlTreeWalker issue. Take a look
at DERBY-4415. This is a slightly more involved solution but may get you
closer. This solution assumes that you are trying to examine the various
phases of the AST for a query against real objects in your database.
This should work with the production jars.

Hope this is more useful,
-Rick

Pavel Bortnovskiy wrote:
>
> Once again, Rick, thanks for your prompt response. To answer your
> questions:
>
> (1) The compilation errors initially had to do with the SanityManager
> and ContextId not available in prod jars.
>
> (2) Since I am trying to get this code to work in our application,
> using debug jars may not be desirable.
> More over, our app is using Derby's in-memory tables as well as its
> NetworkServerController.
> So, this parsing/tree-walking code should not conflict with the other
> two uses.
>
> In the comments for DERBY-791, I did notice "We should provide some
> mechanism for printing these trees in production (non-debug) servers".
> So, I ran XmlTreeWalker linking only to
> db-derby-10.5.3.0-bin/lib/derby.jar, but got the same exception:
>
> 
> 
> select a from t, s where t.a = s.a
> Exception in thread "main" java.sql.SQLSyntaxErrorException:
> Table/View 'T' does not exist.
> at
> 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown

> Source)
> at
> org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
> at
> 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown 


> Source)
> at
> 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown 


> Source)
> at
> org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown
> Source)
> at
> org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown
> Source)
> at
> org.apache.derby.impl.jdbc.EmbedPreparedStatement.(Unknown Source)
> at
> org.apache.derby.impl.jdbc.EmbedPreparedStatement20.(Unknown
> Source)
> at
> org.apache.derby.impl.jdbc.EmbedPreparedStatement30.(Unknown
> Source)
> at
> org.apache.derby.impl.jdbc.EmbedPreparedStatement40.(Unknown
> Source)
> at
> org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Unknown Source)
> at
> org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown
> Source)
> at
> org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown
> Source)
> at XmlTreeWalker.execute(XmlTreeWalker.java:130)
> at XmlTreeWalker.main(XmlTreeWalker.java:111)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) 


>
> at
> 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) 


>
> at java.lang.reflect.Method.invoke(Method.java:597)
> at
> com.intellij.rt.execution.application.AppMain.main(AppMain.java:110)
> Caused by: java.sql.SQLException: Table/View 'T' does not exist.
> at
> org.apache.derby.impl.jdbc.SQLExceptionFactory.getSQLException(Unknown
> Source)
> at
> 
org.apache.derby.impl.jdbc.SQLExceptionFactory40.wrapArgsForTransportAcrossDRDA(Unknown 


> Source)
> ... 20 more
> Caused by: ERROR 42X05: Table/View 'T' does not exist.
> at
> org.apache.derby.iapi.error.StandardException.newException(Unknown
> Source)
> at
> 
org.apache.derby.impl.sql.compile.FromBaseTable.bindTableDescriptor(Unknown 


> Source)
> at
> 
org.apache.derby.impl.sql.compile.FromBaseTable.bindNonVTITables(Unknown

> Source)
> at
> org.apache.derby.impl.sql.compile.FromList.bindTables(

Re: Extracting dependencies from SQL statements

2010-03-09 Thread Pavel Bortnovskiy
Rick: 

your second point grossly understimated the amount of time it took me to 
get frustrated... it was not quick - it was instanteneous - as soon as I 
opened sqlgrammar.jj  ;-D

Last question, then, on the subject. Is there any way to easily simplify 
sqlgrammar.jj, so that it frees itself of all the derby dependencies and 
so that
javacc'ed code can just take a string and give me some kind of lexical 
tree?

Alternatively, javacc project has various .jj files in its repository, two 
of which are PL/SQL-based (there is one for Oracle 9i).
Perhaps using those .jj files may work for my purposes?.. Your thoughts 
would be appreciated.

Thank you for your time and attention.

Pavel.






Rick Hillegas  
Sent by: richard.hille...@sun.com
03/09/2010 02:45 PM
Please respond to
"Derby Discussion" 


To
Derby Discussion 
cc

Subject
Re: Extracting dependencies from SQL statements






Hi Pavel,

Some comments inline...

Pavel Bortnovskiy wrote:
>
> Rick (while I am reading  and trying DERBY-4415), that seems like 
> there is no other way to use prod jars and yet stop the parser from 
> binding?

It looks to me as though the shortcircuiting logic is guarded by a check 
for whether the engine is the debug version.
>
> Would it be at all possible to use the javacc compiler with 
> sqlgrammar.jj (that are probably bundled in derby.jar) to do the work?
I think you will discover that the grammar relies on a fair amount of 
session context supplied by the rest of the Derby SQL interpreter. I 
think you will be frustrated very quickly if you try this approach.

Hope this helps,
-Rick
>
> Pavel.
>
>
>
>
>
> *Rick Hillegas *
> Sent by: richard.hille...@sun.com
>
> 03/09/2010 01:13 PM
> Please respond to
> "Derby Discussion" 
>
>
> 
> To
>Derby Discussion 
> cc
> 
> Subject
>Re: Extracting dependencies from SQL statements
>
>
>
> 
>
>
>
>
>
> Hi Pavel,
>
> You are right, the XmlTreeWalker class also tries to stop the compiler
> after parsing. This can only be done with a debug engine. The error you
> are seeing comes from the bind() phase of compilation. Derby is
> complaining that the query doesn't make sense: the objects it mentions
> don't exist.
>
> There's another issue linked from the XmlTreeWalker issue. Take a look
> at DERBY-4415. This is a slightly more involved solution but may get you
> closer. This solution assumes that you are trying to examine the various
> phases of the AST for a query against real objects in your database.
> This should work with the production jars.
>
> Hope this is more useful,
> -Rick
>
> Pavel Bortnovskiy wrote:
> >
> > Once again, Rick, thanks for your prompt response. To answer your
> > questions:
> >
> > (1) The compilation errors initially had to do with the SanityManager
> > and ContextId not available in prod jars.
> >
> > (2) Since I am trying to get this code to work in our application,
> > using debug jars may not be desirable.
> > More over, our app is using Derby's in-memory tables as well as its
> > NetworkServerController.
> > So, this parsing/tree-walking code should not conflict with the other
> > two uses.
> >
> > In the comments for DERBY-791, I did notice "We should provide some
> > mechanism for printing these trees in production (non-debug) servers".
> > So, I ran XmlTreeWalker linking only to
> > db-derby-10.5.3.0-bin/lib/derby.jar, but got the same exception:
> >
> > 
> > 
> > select a from t, s where t.a = s.a
> > Exception in thread "main" java.sql.SQLSyntaxErrorException:
> > Table/View 'T' does not exist.
> > at
> > 
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
> > Source)
> > at
> > org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
> > at
> > 
> 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown 

>
> > Source)
> > at
> > 
> 
org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown 

>
> > Source)
> > at
> > org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown
> > Source)
> > at
> > org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown
> > Source)
> > at
> > org.apache.derby.impl.jdbc.EmbedPreparedStatement.(Unknown 
Source)
> > at
> > org.apache.derby.impl.jdbc.EmbedPreparedStatement20.(Unknown
> > Source)
> > at
> > org.apache.derby.impl.jdbc.EmbedPreparedStatement30.(Unknown
> > Source)
> > at
> > org.apache.derby.impl.jdbc.EmbedPreparedStatement40.(Unknown
> > Source)
> > at
> > org.apache.derby.jdbc.Driver40.newEmbedPreparedStatement(Unknown 
Source)
> > at
> > org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown
> > Source)
> > at
> > org.apache.derby.impl.jdbc.EmbedConnection.prepareStatement(Unknown
> > Source)
> > at XmlTreeWalker.execute(XmlTreeWalker.java:130)
> > at XmlTreeWalker.main(XmlTreeWalker.java:111)
> > at sun.reflect.NativeMethodAcc

Re: Extracting dependencies from SQL statements

2010-03-09 Thread Rick Hillegas

Hi Pavel,

Some comments inline...

Pavel Bortnovskiy wrote:


Rick:

your second point grossly understimated the amount of time it took me 
to get frustrated... it was not quick - it was instanteneous - as soon 
as I opened sqlgrammar.jj  ;-D


Last question, then, on the subject. Is there any way to easily 
simplify sqlgrammar.jj, so that it frees itself of all the derby 
dependencies and so that
javacc'ed code can just take a string and give me some kind of lexical 
tree?
This sounds like a frustrating approach too. If you are willing to hack 
the Derby code and create your owned forked version, then I would 
recommend going into GenericStatement.java and hacking the prepMinion() 
method so that you can control the short-circuiting yourself. Look for 
the string StopAfterParsing.


Alternatively, javacc project has various .jj files in its repository, 
two of which are PL/SQL-based (there is one for Oracle 9i).
Perhaps using those .jj files may work for my purposes?.. Your 
thoughts would be appreciated.
I have never looked at those grammars so I can't advise you here. This 
approach also will be peppered with frustrations if what you want to 
achieve is a Derby-powered app which performs some extra dependency 
tracking. Since the javacc-supplied grammars aren't the Derby grammar, 
statements which parse in one grammar may not parse in the other.


So let's step back for a moment. What do you need to achieve here:

o Are you writing a Derby-powered app or just trying to use the Derby 
parser against statements which actually run in some other database?


o If this is a Derby-powered app, do you need to track the dependencies 
before the statement is executed?


Thanks,
-Rick


Thank you for your time and attention.

Pavel.





*Rick Hillegas *
Sent by: richard.hille...@sun.com

03/09/2010 02:45 PM
Please respond to
"Derby Discussion" 



To
Derby Discussion 
cc

Subject
Re: Extracting dependencies from SQL statements









Hi Pavel,

Some comments inline...

Pavel Bortnovskiy wrote:
>
> Rick (while I am reading  and trying DERBY-4415), that seems like
> there is no other way to use prod jars and yet stop the parser from
> binding?

It looks to me as though the shortcircuiting logic is guarded by a check
for whether the engine is the debug version.
>
> Would it be at all possible to use the javacc compiler with
> sqlgrammar.jj (that are probably bundled in derby.jar) to do the work?
I think you will discover that the grammar relies on a fair amount of
session context supplied by the rest of the Derby SQL interpreter. I
think you will be frustrated very quickly if you try this approach.

Hope this helps,
-Rick
>
> Pavel.
>
>
>
>
>
> *Rick Hillegas *
> Sent by: richard.hille...@sun.com
>
> 03/09/2010 01:13 PM
> Please respond to
> "Derby Discussion" 
>
>
>  
> To

>  Derby Discussion 
> cc
>  
> Subject

>  Re: Extracting dependencies from SQL statements
>
>
>
>  
>

>
>
>
>
> Hi Pavel,
>
> You are right, the XmlTreeWalker class also tries to stop the compiler
> after parsing. This can only be done with a debug engine. The error you
> are seeing comes from the bind() phase of compilation. Derby is
> complaining that the query doesn't make sense: the objects it mentions
> don't exist.
>
> There's another issue linked from the XmlTreeWalker issue. Take a look
> at DERBY-4415. This is a slightly more involved solution but may get you
> closer. This solution assumes that you are trying to examine the various
> phases of the AST for a query against real objects in your database.
> This should work with the production jars.
>
> Hope this is more useful,
> -Rick
>
> Pavel Bortnovskiy wrote:
> >
> > Once again, Rick, thanks for your prompt response. To answer your
> > questions:
> >
> > (1) The compilation errors initially had to do with the SanityManager
> > and ContextId not available in prod jars.
> >
> > (2) Since I am trying to get this code to work in our application,
> > using debug jars may not be desirable.
> > More over, our app is using Derby's in-memory tables as well as its
> > NetworkServerController.
> > So, this parsing/tree-walking code should not conflict with the other
> > two uses.
> >
> > In the comments for DERBY-791, I did notice "We should provide some
> > mechanism for printing these trees in production (non-debug) servers".
> > So, I ran XmlTreeWalker linking only to
> > db-derby-10.5.3.0-bin/lib/derby.jar, but got the same exception:
> >
> > 
> > 
> > select a from t, s where t.a = s.a
> > Exception in thread "main" java.sql.SQLSyntaxErrorException:
> > Table/View 'T' does not exist.
> > at
> >
> org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown
> > Source)
> > at
> > org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
> > at
> >
> 
org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQL

Re: Extracting dependencies from SQL statements

2010-03-09 Thread Pavel Bortnovskiy
Rick:

thank you for your patience and continuing support on this issue.

(1) Even prior to your email, I grepped for StopAfterParsing and found the 
code you are referring to in GenericStatement.java.
I am not too keen on going that route, since that would require rebuilding 
Derby and I would rather not temper with prod-quality code.

(2) I have downloaded that PlSql.jj and ran javacc on it. It generated a 
bunch of java files and with a small change to the main, I got it to 
report:

Tables in "select (select 1 from dual), a.string, b.string from a, b where 
exists (select * from c where c.id = a.id);":
A
B
C
DUAL

This is what I am looking for.

(3) My application is Derby powered. The app is relying on Derby's 
in-memory tables for internal data exchange and NetworkServerController to 
monitor these tables from the outside 
of the application. However, just as you properly assumed, parts of my 
application need to analyze dependencies. So, a portion of the application 
(with a configured select) may depend on other
components (whose data may be accessed by the configured select). So, 
while making that dependency analysis, I would need to get a list of all 
the tables referenced in the select.
So far I have done a regex search for the word where and then had to do 
some hacky parsing thereafter. But I don't like that approach. Besides, in 
the current form it wouldn't be able to
handle more complex, nested statements (as the one above that I've tested 
PlSql.jj with).

(4) Off this particular topic. While looking through Derby's code I 
discovered to my amazement that Derby is using OSGi (Apache Felix). Can 
you please take a moment and enlighten me 
a little on what it is used for? The reason why I am asking is that I am 
using already a lot of Apache code (CLI, CODEC, DBCP, POOL) besides 
extensive use of Derby. But now I am keenly interested in refactoring my 
application to use OSGi. I have been looking at two alternatives - Spring 
and Felix and I've been leaning towards Felix. Seeing that Derby is using 
it as well makes me even more inclined
to proceed in that direction.


Thanks,
Pavel.






Rick Hillegas  
Sent by: richard.hille...@sun.com
03/09/2010 03:39 PM
Please respond to
"Derby Discussion" 


To
Derby Discussion 
cc

Subject
Re: Extracting dependencies from SQL statements






Hi Pavel,

Some comments inline...

Pavel Bortnovskiy wrote:
>
> Rick:
>
> your second point grossly understimated the amount of time it took me 
> to get frustrated... it was not quick - it was instanteneous - as soon 
> as I opened sqlgrammar.jj  ;-D
>
> Last question, then, on the subject. Is there any way to easily 
> simplify sqlgrammar.jj, so that it frees itself of all the derby 
> dependencies and so that
> javacc'ed code can just take a string and give me some kind of lexical 
> tree?
This sounds like a frustrating approach too. If you are willing to hack 
the Derby code and create your owned forked version, then I would 
recommend going into GenericStatement.java and hacking the prepMinion() 
method so that you can control the short-circuiting yourself. Look for 
the string StopAfterParsing.
>
> Alternatively, javacc project has various .jj files in its repository, 
> two of which are PL/SQL-based (there is one for Oracle 9i).
> Perhaps using those .jj files may work for my purposes?.. Your 
> thoughts would be appreciated.
I have never looked at those grammars so I can't advise you here. This 
approach also will be peppered with frustrations if what you want to 
achieve is a Derby-powered app which performs some extra dependency 
tracking. Since the javacc-supplied grammars aren't the Derby grammar, 
statements which parse in one grammar may not parse in the other.

So let's step back for a moment. What do you need to achieve here:

o Are you writing a Derby-powered app or just trying to use the Derby 
parser against statements which actually run in some other database?

o If this is a Derby-powered app, do you need to track the dependencies 
before the statement is executed?

Thanks,
-Rick
>
> Thank you for your time and attention.
>
> Pavel.
>
>
>
>
>
> *Rick Hillegas *
> Sent by: richard.hille...@sun.com
>
> 03/09/2010 02:45 PM
> Please respond to
> "Derby Discussion" 
>
>
> 
> To
>Derby Discussion 
> cc
> 
> Subject
>Re: Extracting dependencies from SQL statements
>
>
>
> 
>
>
>
>
>
> Hi Pavel,
>
> Some comments inline...
>
> Pavel Bortnovskiy wrote:
> >
> > Rick (while I am reading  and trying DERBY-4415), that seems like
> > there is no other way to use prod jars and yet stop the parser from
> > binding?
>
> It looks to me as though the shortcircuiting logic is guarded by a check
> for whether the engine is the debug version.
> >
> > Would it be at all possible to use the javacc compiler with
> > sqlgrammar.jj (that are probably bundled in derby.jar) to do the work?
> I think you will discover that the grammar relies on a fair a

Re: JNLP setup creating an apache derby db fails - versuchen01X

2010-03-09 Thread Knut Anders Hatlen
Gabriele Kahlout  writes:

> is there a link to this email conv, so that I post it to
> http://forums.sun.com/thread.jspa?messageID=10947198� ?

http://thread.gmane.org/gmane.comp.apache.db.derby.user/12297

-- 
Knut Anders