Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes JBoss/WildFly and the fly likes Connection Pooling in JBoss v5.0 with IBM DB2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "Connection Pooling in JBoss v5.0 with IBM DB2" Watch "Connection Pooling in JBoss v5.0 with IBM DB2" New topic
Author

Connection Pooling in JBoss v5.0 with IBM DB2

damodaran puliyassery
Greenhorn

Joined: Dec 17, 2009
Posts: 13

I modify the db2-ds.xml file and put it in server/default/deploy folder.The file is

<?xml version="1.0" encoding="UTF-8"?>

<!-- ===================================================================== -->
<!-- -->
<!-- JBoss Server Configuration -->
<!-- -->
<!-- ===================================================================== -->

<!-- $Id: db2-ds.xml 43824 2006-04-16 21:48:44Z wprice $ -->


<datasources>
<local-tx-datasource>
<jndi-name>test</jndi-name>
<connection-url>jdbc:db2://localhost:50000/dbinventory</connection-url>

<!-- DB2 Universal Driver Note connection URL is in form of
jdbc:db2://host:port:dbname

Default port for Type 4 driver is 50000

Note, host and port must be specified if using Type 4 driver. And be forewarned, no native
XA support is provided with Type 4; you must set a DB property calling for Type 2 to get XA

<driver-class>com.ibm.db2.jcc.DB2Driver</driver-class>
<connection-url>jdbc:db2://[hostname]:[port]/databasename"</connection-url>

Please see http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0512kokkat/
or the DB2 JDBC application developers manual.
-->

<driver-class>COM.ibm.db2.jdbc.app.DB2Driver</driver-class>
<user-name>admin</user-name>
<password>admin</password>
<min-pool-size>0</min-pool-size>
<max-pool-size>50</max-pool-size>

<!-- New org.jboss.resource.adapter.jdbc.vendor.DB2ExceptionSorter

<exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.DB2ExceptionSorter</exception-sorter-class-name>

-->

<!-- sql to call when connection is created
<new-connection-sql>some arbitrary sql</new-connection-sql>
-->

<!-- sql to call on an existing pooled connection when it is obtained from pool
<check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
-->

<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml (optional) -->


<metadata>
<type-mapping>DB2</type-mapping>
</metadata>
</local-tx-datasource>

</datasources>


And in J2EE i write this code
try
{
ic=new javax.naming.InitialContext();
ds=(javax.sql.DataSource)ic.lookup("test");
conn=ds.getConnection();
}
catch(Exception e)
{
System.out.println("Error in DBConnection "+e.getMessage());
}

But i got this error Message:- Error in DBConnection test not bound
I have to do any more changes?Why this error??Somebody please help......
thanks in advance....
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 10048
    
163

See this


[My Blog] [JavaRanch Journal]
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5823
    
    7

Damodaran, in the future please use the "code" tags to post source code. You can do that by selecting the source code and clicking the Code button above the editor window. It makes posts much easier to read. (You can practice by editing your post to use the Code tags.)

Oh, and welcome to Java Ranch!


JBoss In Action
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Connection Pooling in JBoss v5.0 with IBM DB2