You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by mohamed ramzy <m_...@yahoo.com> on 2000/06/01 14:03:06 UTC

SQL-Null-Pointer-Exception!!!!!!!!!

hi
i'm trying to make a dynamic queries by useing
SQLtaglib...

i did the following :

<sql:execute-query>
<sql:driver>org.gjt.mm.mysql.Driver</sql:driver>
<sql:dburl>jdbc:mysql://localhost/Ramzy1</sql:dburl>
<sql:username>rrr</sql:username>
<sql:password>rrr</sql:password>
<sql:query>select name,owner from pet  </sql:query>
</sql:execute-query>


and i got the NULLPointerException error...does any 1
knows what is going on !!!!!!?????

NB: i did the same query with normal cocoon's SQL and
it worked but i found that i can't make dynamic query
unless by useing SQLTaglib....!!!!

Thanx in Advance

=====


__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/

Re: SQL-Null-Pointer-Exception!!!!!!!!!

Posted by Donald Ball <ba...@webslingerZ.com>.
On Thu, 1 Jun 2000, mohamed ramzy wrote:

> hi
> i'm trying to make a dynamic queries by useing
> SQLtaglib...
> 
> i did the following :
> 
> <sql:execute-query>
> <sql:driver>org.gjt.mm.mysql.Driver</sql:driver>
> <sql:dburl>jdbc:mysql://localhost/Ramzy1</sql:dburl>
> <sql:username>rrr</sql:username>
> <sql:password>rrr</sql:password>
> <sql:query>select name,owner from pet  </sql:query>
> </sql:execute-query>
> 
> 
> and i got the NULLPointerException error...does any 1
> knows what is going on !!!!!!?????
> 
> NB: i did the same query with normal cocoon's SQL and
> it worked but i found that i can't make dynamic query
> unless by useing SQLTaglib....!!!!

What version of cocoon are you using? Older versions would give an NPE if
you didn't specify a doc-element. Try upgrading or adding a doc-element,
or post your full stacktrace.

- donald


Re: SQL-Null-Pointer-Exception!!!!!!!!!

Posted by Michele Bianchi <mi...@aesthetica.it>.
On Thu, 1 Jun 2000, Donald Ball wrote:

> FYI, I use this technique extensively. Instead of saying something like
> this:
> 
> <sql:execute-query>
>  ... blah blah driver etc blah ...
>  <sql:query>select id,name from employee_table</sql:query>
> </sql:execute-query>
> 
> i say something like this:
> 
> <employees:list/>

yep!  but i have another kind of problem... i need to restart the jserv to
"recompile" the .xsl (the namespace, is it correct?) and in the devel phase
it's a pain.  any suggestion?

back to db pool.  now i'm trying a simple db pool.  a stupid vector and a get
and put function for dbconnection.  probably i'll need something more for
statement and preparedstatement, but, you know, i need a starting point.  my
idea is to branch a "debug-version" of sql tag lib that "get" the dbconnection
from the pool.  that let me to speedup devel before "freeze" and use your
technique.

the sql tag lib is so flexible for the initial stages of developing.  now i
have 3 prototype and each one uses their db (dburl, user, passwd).  my target
is to create the db pools in the config file, than access with the sql tag lib
through a "connection name".

what do you think about?

tia

michele

-------------------------------------------------------------------------------
michele_bianchi                                  exsense | integrated_solutions
phone://+39_348_7651874                                       via_scrimiari_45b
http://mic.aesthetica.it                                     37132_verona_italy


Re: SQL-Null-Pointer-Exception!!!!!!!!!

Posted by Donald Ball <ba...@webslingerZ.com>.
On Thu, 1 Jun 2000, Michele Bianchi wrote:

>    <sql:execute-query>
>     <eguru:db/>
>     <sql:row-element>property</sql:row-element>
>       
>     <sql:query>SELECT  prop_desc.name,prop_desc.weight,prop_desc.id,prop_group.name FROM prop_desc,prop_group WHERE  prop_desc.id!=0 AND prop_desc.grp=prop_group.id ORDER BY prop_desc.name</sql:query>
>    </sql:execute-query>
> 
> where <eguru:db/> is:
> 
>  <xsl:template match="eguru:db">
>   <sql:driver>postgresql.Driver</sql:driver>
>   <sql:dburl>jdbc:postgresql://localhost/eguru</sql:dburl>
>   <sql:username>mic</sql:username>
>   <sql:password></sql:password>
>  </xsl:template>
> 
> that helps me to have a more compact and easy to change definition of db.  and
> e.g. for java code i use the tag <eguru:db-raw>:
> 
>  <xsl:template match="eguru:db-raw">
>   Class.forName ("postgresql.Driver");
>   Connection db = DriverManager.getConnection ("jdbc:postgresql://localhost/eguru", "mic", "");
>  </xsl:template>

FYI, I use this technique extensively. Instead of saying something like
this:

<sql:execute-query>
 ... blah blah driver etc blah ...
 <sql:query>select id,name from employee_table</sql:query>
</sql:execute-query>

i say something like this:

<employees:list/>

and use XSLT to transform the simple, literate tags into the nitty gritty
sql. it's obviously much more useful with more complex queries with
parameters and such, but you get the gist.

- donald


Re: SQL-Null-Pointer-Exception!!!!!!!!!

Posted by Michele Bianchi <mi...@aesthetica.it>.
this one works to me:

   <sql:execute-query>
    <eguru:db/>
    <sql:row-element>property</sql:row-element>
      
    <sql:query>SELECT  prop_desc.name,prop_desc.weight,prop_desc.id,prop_group.name FROM prop_desc,prop_group WHERE  prop_desc.id!=0 AND prop_desc.grp=prop_group.id ORDER BY prop_desc.name</sql:query>
   </sql:execute-query>

where <eguru:db/> is:

 <xsl:template match="eguru:db">
  <sql:driver>postgresql.Driver</sql:driver>
  <sql:dburl>jdbc:postgresql://localhost/eguru</sql:dburl>
  <sql:username>mic</sql:username>
  <sql:password></sql:password>
 </xsl:template>

that helps me to have a more compact and easy to change definition of db.  and
e.g. for java code i use the tag <eguru:db-raw>:

 <xsl:template match="eguru:db-raw">
  Class.forName ("postgresql.Driver");
  Connection db = DriverManager.getConnection ("jdbc:postgresql://localhost/eguru", "mic", "");
 </xsl:template>



On Thu, 1 Jun 2000, mohamed ramzy wrote:

> i did the following :
> 
> <sql:execute-query>
> <sql:driver>org.gjt.mm.mysql.Driver</sql:driver>
> <sql:dburl>jdbc:mysql://localhost/Ramzy1</sql:dburl>
> <sql:username>rrr</sql:username>
> <sql:password>rrr</sql:password>
> <sql:query>select name,owner from pet  </sql:query>
> </sql:execute-query>

-------------------------------------------------------------------------------
michele_bianchi                                  exsense | integrated_solutions
phone://+39_348_7651874                                       via_scrimiari_45b
http://mic.aesthetica.it                                     37132_verona_italy