You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Nicolas Rod <co...@alaxos.com> on 2004/12/07 14:03:32 UTC
jdbc problem in a custom generator
Hi,
I'm quite new to cocoon and I'm trying to make a jdbc connection in a
custom generator but I always get this error which can be found in the
sitemap.log: 'java.sql.SQLException: No suitable driver'
Here's the code I use in my generator:
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn = DriverManager.getConnection(url, username, password);
I also tried with:
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection(url, username, password);
Both codes give me the same error.
If I try to instanciate the OracleDriver like the following code, the
debug shows me "od isn't 'null'", meaning the driver class is found.
OracleDriver od = new oracle.jdbc.driver.OracleDriver();
if(od==null)
getLogger().debug("od is 'null'");
else
getLogger().debug("od isn't 'null'");
The driver class is loaded in the web.xml, as I know it has to be.
If I use the same code in simple Java class, out of cocoon, it connects
without any problem.
Does anyone have any idea why this happens ?
Thanks,
Nicolas
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: jdbc problem in a custom generator
Posted by Nicolas Rod <co...@alaxos.com>.
Hi Ugo,
Thanks a lot, you pointed exactly my mistake. The error message made me
think it was a driver related problem. For this reason, I didn't double
check the url... which was malformed...
Thanks for the precision regarding the cocoon.xconf as well.
Ugo Cei wrote:
> Il giorno 07/dic/04, alle 14:03, Nicolas Rod ha scritto:
>
>> I'm quite new to cocoon and I'm trying to make a jdbc connection in a
>> custom generator but I always get this error which can be found in the
>> sitemap.log: 'java.sql.SQLException: No suitable driver'
>>
>> Here's the code I use in my generator:
>>
>> Class.forName("oracle.jdbc.driver.OracleDriver");
>> Connection conn = DriverManager.getConnection(url, username,
>> password);
>>
>> I also tried with:
>>
>> DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
>> Connection conn = DriverManager.getConnection(url, username,
>> password);
>>
>> Both codes give me the same error.
>
>
> Your code looks fine to me. Are you sure you are using the right kind of
> url? It should be something like "jdbc:oracle:thin:@hostname:1521:SID".
>
>>
>> The driver class is loaded in the web.xml, as I know it has to be.
>
>
> It does not have to be, if you are loading the driver by yourself, like
> in the above code. It has to be only if you declare a datasource
> component in cocoon.xconf, which does not seem to be your case.
>
> Ugo
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: jdbc problem in a custom generator
Posted by Ugo Cei <ug...@apache.org>.
Il giorno 07/dic/04, alle 14:03, Nicolas Rod ha scritto:
> I'm quite new to cocoon and I'm trying to make a jdbc connection in a
> custom generator but I always get this error which can be found in the
> sitemap.log: 'java.sql.SQLException: No suitable driver'
>
> Here's the code I use in my generator:
>
> Class.forName("oracle.jdbc.driver.OracleDriver");
> Connection conn = DriverManager.getConnection(url, username,
> password);
>
> I also tried with:
>
> DriverManager.registerDriver (new
> oracle.jdbc.driver.OracleDriver());
> Connection conn = DriverManager.getConnection(url, username,
> password);
>
> Both codes give me the same error.
Your code looks fine to me. Are you sure you are using the right kind
of url? It should be something like
"jdbc:oracle:thin:@hostname:1521:SID".
>
> The driver class is loaded in the web.xml, as I know it has to be.
It does not have to be, if you are loading the driver by yourself, like
in the above code. It has to be only if you declare a datasource
component in cocoon.xconf, which does not seem to be your case.
Ugo
--
Ugo Cei - http://beblogging.com/
Re: jdbc problem in a custom generator
Posted by Christoph Kliemt <ch...@entici.de>.
Nicolas Rod <co...@alaxos.com> writes:
> Hi,
>
> I'm quite new to cocoon and I'm trying to make a jdbc connection in a
> custom generator but I always get this error which can be found in the
> sitemap.log: 'java.sql.SQLException: No suitable driver'
run the java vm with -verbose:class an see if the driver gets loaded.
hth
christoph
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org