You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by "Marc Weber (H2Opilot)" <we...@h2opilot.de> on 2001/08/20 13:53:13 UTC

problems trying to initialize a Connectionpool in Struts

Hello !

i am encountering problems by trying to initialize a
Database Connnectionpool.

in struts-config.xml I got the entries:

....

<data-sources>
	<data-source
		autoCommit="false"
		description="H2O DATENBANKTEST"
		driverClass="org.gjt.mm.mysql.Driver"
		maxCount="15" minCount="2"
		url="jdbc:mysql://IP/DBname"
		user="username"
		password="******"
		key="theKey"/>
</data-sources>

....

but by trying to acces these values by the call

 try {
     GenericDataSource dataSource =
(GenericDataSource)servlet.getServletContext().getAttribute(Action.DATA_SOUR
CE_KEY);
      conn = dataSource.getConnection();

      .....
         //here are my MySQL instructions etc......

I got a NULLPOINTEREXCEPTION
If I initialize these values directly via the call
        dataSource.setAutoCommit(false); Etc....  inside the method
erverything works.

BUT I HAVE TO READ THESE VALUES FROM THE STRUTS-CONFIG!
WHO CAN HELP A POOR FRUSTRATED JSP DEVELOPER (BEGINNER) ?



Re: problems trying to initialize a Connectionpool in Struts

Posted by Ted Husted <hu...@apache.org>.
The best place to post questions like this is the User list, where there
are more people who can help you.

But, you should either take out the key property, or pass it again
later. If you leave it out, then Struts will use the DATA_SOURCE_KEY for
a default. 

See also the ActionServlet method for returning a datasource the generic
pool.

"Marc Weber (H2Opilot)" wrote:
> 
> Hello !
> 
> i am encountering problems by trying to initialize a
> Database Connnectionpool.
> 
> in struts-config.xml I got the entries:
> 
> ....
> 
> <data-sources>
>         <data-source
>                 autoCommit="false"
>                 description="H2O DATENBANKTEST"
>                 driverClass="org.gjt.mm.mysql.Driver"
>                 maxCount="15" minCount="2"
>                 url="jdbc:mysql://IP/DBname"
>                 user="username"
>                 password="******"
>                 key="theKey"/>
> </data-sources>
> 
> ....
> 
> but by trying to acces these values by the call
> 
>  try {
>      GenericDataSource dataSource =
> (GenericDataSource)servlet.getServletContext().getAttribute(Action.DATA_SOUR
> CE_KEY);
>       conn = dataSource.getConnection();
> 
>       .....
>          //here are my MySQL instructions etc......
> 
> I got a NULLPOINTEREXCEPTION
> If I initialize these values directly via the call
>         dataSource.setAutoCommit(false); Etc....  inside the method
> erverything works.
> 
> BUT I HAVE TO READ THESE VALUES FROM THE STRUTS-CONFIG!
> WHO CAN HELP A POOR FRUSTRATED JSP DEVELOPER (BEGINNER) ?