You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by dileep_sivaraman <di...@infosys.com> on 2007/07/27 08:58:21 UTC

registering a DB2ConnectionPoolDataSource in tomcat 5.5

Hi ,

I am trying to register a com.ibm.db2.jcc.DB2ConnectionPoolDataSource
datasource in tomcat 5.5.4.

I am not getting any exception's while doing a context lookup and gives me
the datasource.
However the paramaeter's that are set with that Resource are always null.

Server.xml
<GlobalNamingResources>
<Resource name="jdbc/db2universal"
type="com.ibm.db2.jcc.DB2ConnectionPoolDataSource"
factory="com.ibm.db2.jcc.DB2DataSourceFactory"
serverName="PROD9S03.bankofamerica.com" username="abc" password="abc"/>

</GlobalNamingResources>

In my code  I get the datasource as :

connPoolDataSource=(DB2ConnectionPoolDataSource)
envContext.lookup("jdbc/db2universal");

However when I print out the serverName parameter that has been set in the
resource it prints null.

System.out.println("connPoolDataSource.getServerName()
:"+connPoolDataSource.getServerName());

OUTPUT:

connPoolDataSource.getServerName() :null


Can somebody tell me what I  am doing wrong?
-- 
View this message in context: http://www.nabble.com/registering-a-DB2ConnectionPoolDataSource-in-tomcat--5.5-tf4155802.html#a11823991
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: registering a DB2ConnectionPoolDataSource in tomcat 5.5

Posted by Mohammed Zabin <jo...@gmail.com>.
On 7/27/07, dileep_sivaraman <di...@infosys.com> wrote:
>
>
> Hi,
> > Thrid: Add extra information in your web.xml file like the following:
> > <resource-ref>
> >      <description>Oracle Datasource example</description>
> >      <res-ref-name>jdbc/db2universal</res-ref-name>
> >      <res-type>javax.sql.DataSource</res-type>
> >      <res-auth>Container</res-auth>
> >    </resource-ref>
>
>
> > Do we have to add this since I am defining the resource as global?
> You are right, i think that you don't have to add the above in web.xml, I
> tried to remove it from Oracle configuration and MySql, and it works.


The most important thing, is to defing a resource in server.xml, and then
linke your resource to the server enviroment in context.xml

OUTPUT :
>
> PRinting out entries in java:comp/env
> Entry :jdbc: org.apache.naming.NamingContext
> PRinting out entries in java:comp/env/jdbc
> Entry :db2universal: org.apache.naming.ResourceLinkRef
> It is not null
> ********************************
> connPoolDataSource.getServerName() :null
> Port:446
> DB Name:null
> Driver type :2
> Timeout :0
> User :null
>
> Is there any way to print out the parameters that are passed along with
> the
> Resource?
> Or am I doing something fundamentally wrong?
>
>
>
> Mohammed Zabin wrote:
> >
> > I didn't work on DB2 before, but i have configured Oracle and MySql
> > database in the same way.
> >
> > First, you have to get the ideal connector for DB2, jar file, and
> > place it inside CATALINA_HOME/lib, or JAVA_HOME/lib/ext.
> >
> > Second, Define your resource name, you already did.
> >
> > Thrid: Add extra information in your web.xml file like the following:
> > <resource-ref>
> >       <description>Oracle Datasource example</description>
> >       <res-ref-name>jdbc/db2universal</res-ref-name>
> >       <res-type>javax.sql.DataSource</res-type>
> >       <res-auth>Container</res-auth>
> >     </resource-ref>
> >
> > After that, you have to connect your Resource name to the your server.
> > In context.xml add the following line of code:
> >
> > <ResourceLink global="jdbc/db2universal" name="jdbc/db2universal"
> > type="javax.sql.DataSource"/>
> >
> > One last thing, please note that you have to change the previous
> > parameters according to your database. Hope that will help
> > On 7/27/07, dileep_sivaraman <di...@infosys.com> wrote:
> >>
> >> Hi ,
> >>
> >> I am trying to register a com.ibm.db2.jcc.DB2ConnectionPoolDataSource
> >> datasource in tomcat 5.5.4.
> >>
> >> I am not getting any exception's while doing a context lookup and gives
> >> me
> >> the datasource.
> >> However the paramaeter's that are set with that Resource are always
> null.
> >>
> >> Server.xml
> >> <GlobalNamingResources>
> >> <Resource name="jdbc/db2universal"
> >> type="com.ibm.db2.jcc.DB2ConnectionPoolDataSource"
> >> factory="com.ibm.db2.jcc.DB2DataSourceFactory"
> >> serverName="PROD9S03.bankofamerica.com" username="abc" password="abc"/>
> >>
> >> </GlobalNamingResources>
> >>
> >> In my code  I get the datasource as :
> >>
> >> connPoolDataSource=(DB2ConnectionPoolDataSource)
> >> envContext.lookup("jdbc/db2universal");
> >>
> >> However when I print out the serverName parameter that has been set in
> >> the
> >> resource it prints null.
> >>
> >> System.out.println("connPoolDataSource.getServerName()
> >> :"+connPoolDataSource.getServerName());
> >>
> >> OUTPUT:
> >>
> >> connPoolDataSource.getServerName() :null
> >>
> >>
> >> Can somebody tell me what I  am doing wrong?
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/registering-a-DB2ConnectionPoolDataSource-in-tomcat--5.5-tf4155802.html#a11823991
> >> Sent from the Tomcat - User mailing list archive at Nabble.com.
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To start a new topic, e-mail: users@tomcat.apache.org
> >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> >> For additional commands, e-mail: users-help@tomcat.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To start a new topic, e-mail: users@tomcat.apache.org
> > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: users-help@tomcat.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/registering-a-DB2ConnectionPoolDataSource-in-tomcat--5.5-tf4155802.html#a11824613
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

Re: registering a DB2ConnectionPoolDataSource in tomcat 5.5

Posted by dileep_sivaraman <di...@infosys.com>.
Hi,
> Thrid: Add extra information in your web.xml file like the following: 
> <resource-ref> 
>      <description>Oracle Datasource example</description> 
>      <res-ref-name>jdbc/db2universal</res-ref-name> 
>      <res-type>javax.sql.DataSource</res-type> 
>      <res-auth>Container</res-auth> 
>    </resource-ref> 


Do we have to add this since I am defining the resource as global?

Secondly I am getting the datasource reference from jndi but it seems to
loose it's parameters,


OUTPUT :

PRinting out entries in java:comp/env
Entry :jdbc: org.apache.naming.NamingContext
PRinting out entries in java:comp/env/jdbc
Entry :db2universal: org.apache.naming.ResourceLinkRef
It is not null
********************************
connPoolDataSource.getServerName() :null
 Port:446
 DB Name:null
Driver type :2
Timeout :0
User :null

Is there any way to print out the parameters that are passed along with the
Resource?
Or am I doing something fundamentally wrong?



Mohammed Zabin wrote:
> 
> I didn't work on DB2 before, but i have configured Oracle and MySql
> database in the same way.
> 
> First, you have to get the ideal connector for DB2, jar file, and
> place it inside CATALINA_HOME/lib, or JAVA_HOME/lib/ext.
> 
> Second, Define your resource name, you already did.
> 
> Thrid: Add extra information in your web.xml file like the following:
> <resource-ref>
>       <description>Oracle Datasource example</description>
>       <res-ref-name>jdbc/db2universal</res-ref-name>
>       <res-type>javax.sql.DataSource</res-type>
>       <res-auth>Container</res-auth>
>     </resource-ref>
> 
> After that, you have to connect your Resource name to the your server.
> In context.xml add the following line of code:
> 
> <ResourceLink global="jdbc/db2universal" name="jdbc/db2universal"
> type="javax.sql.DataSource"/>
> 
> One last thing, please note that you have to change the previous
> parameters according to your database. Hope that will help
> On 7/27/07, dileep_sivaraman <di...@infosys.com> wrote:
>>
>> Hi ,
>>
>> I am trying to register a com.ibm.db2.jcc.DB2ConnectionPoolDataSource
>> datasource in tomcat 5.5.4.
>>
>> I am not getting any exception's while doing a context lookup and gives
>> me
>> the datasource.
>> However the paramaeter's that are set with that Resource are always null.
>>
>> Server.xml
>> <GlobalNamingResources>
>> <Resource name="jdbc/db2universal"
>> type="com.ibm.db2.jcc.DB2ConnectionPoolDataSource"
>> factory="com.ibm.db2.jcc.DB2DataSourceFactory"
>> serverName="PROD9S03.bankofamerica.com" username="abc" password="abc"/>
>>
>> </GlobalNamingResources>
>>
>> In my code  I get the datasource as :
>>
>> connPoolDataSource=(DB2ConnectionPoolDataSource)
>> envContext.lookup("jdbc/db2universal");
>>
>> However when I print out the serverName parameter that has been set in
>> the
>> resource it prints null.
>>
>> System.out.println("connPoolDataSource.getServerName()
>> :"+connPoolDataSource.getServerName());
>>
>> OUTPUT:
>>
>> connPoolDataSource.getServerName() :null
>>
>>
>> Can somebody tell me what I  am doing wrong?
>> --
>> View this message in context:
>> http://www.nabble.com/registering-a-DB2ConnectionPoolDataSource-in-tomcat--5.5-tf4155802.html#a11823991
>> Sent from the Tomcat - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@tomcat.apache.org
>> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
>> For additional commands, e-mail: users-help@tomcat.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/registering-a-DB2ConnectionPoolDataSource-in-tomcat--5.5-tf4155802.html#a11824613
Sent from the Tomcat - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Re: registering a DB2ConnectionPoolDataSource in tomcat 5.5

Posted by Mohammed Zabin <jo...@gmail.com>.
I didn't work on DB2 before, but i have configured Oracle and MySql
database in the same way.

First, you have to get the ideal connector for DB2, jar file, and
place it inside CATALINA_HOME/lib, or JAVA_HOME/lib/ext.

Second, Define your resource name, you already did.

Thrid: Add extra information in your web.xml file like the following:
<resource-ref>
      <description>Oracle Datasource example</description>
      <res-ref-name>jdbc/db2universal</res-ref-name>
      <res-type>javax.sql.DataSource</res-type>
      <res-auth>Container</res-auth>
    </resource-ref>

After that, you have to connect your Resource name to the your server.
In context.xml add the following line of code:

<ResourceLink global="jdbc/db2universal" name="jdbc/db2universal"
type="javax.sql.DataSource"/>

One last thing, please note that you have to change the previous
parameters according to your database. Hope that will help
On 7/27/07, dileep_sivaraman <di...@infosys.com> wrote:
>
> Hi ,
>
> I am trying to register a com.ibm.db2.jcc.DB2ConnectionPoolDataSource
> datasource in tomcat 5.5.4.
>
> I am not getting any exception's while doing a context lookup and gives me
> the datasource.
> However the paramaeter's that are set with that Resource are always null.
>
> Server.xml
> <GlobalNamingResources>
> <Resource name="jdbc/db2universal"
> type="com.ibm.db2.jcc.DB2ConnectionPoolDataSource"
> factory="com.ibm.db2.jcc.DB2DataSourceFactory"
> serverName="PROD9S03.bankofamerica.com" username="abc" password="abc"/>
>
> </GlobalNamingResources>
>
> In my code  I get the datasource as :
>
> connPoolDataSource=(DB2ConnectionPoolDataSource)
> envContext.lookup("jdbc/db2universal");
>
> However when I print out the serverName parameter that has been set in the
> resource it prints null.
>
> System.out.println("connPoolDataSource.getServerName()
> :"+connPoolDataSource.getServerName());
>
> OUTPUT:
>
> connPoolDataSource.getServerName() :null
>
>
> Can somebody tell me what I  am doing wrong?
> --
> View this message in context:
> http://www.nabble.com/registering-a-DB2ConnectionPoolDataSource-in-tomcat--5.5-tf4155802.html#a11823991
> Sent from the Tomcat - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org