Results 1 to 5 of 5

Thread: Using DB2 datasource

  1. #1
    Join Date
    Nov 2006
    Posts
    4

    Default Using DB2 datasource

    Hi,

    I am trying to connect to DB2 using the following code in applicationContext.xml:

    <bean id="testDataSource" class="COM.ibm.db2.jdbc.DB2BasicDataSource" destroy-method="close">
    <property name="serverName">
    <value>db2tst01.es.ssmb.com</value>
    </property>
    <property name="portNumber">
    <value>438</value>
    </property>
    <property name="databaseName">
    <value>...</value>
    </property>
    <property name="user">
    <value>...</value>
    </property>
    <property name="password">
    <value>...</value>
    </property>
    </bean>

    but when I try using testDataSource as a dataSource reference in another bean clientDAO, I get this error:
    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name 'clientDAO' defined in class path resource [WEB-INF/applicationContext.xml]: Error setting property values; nested exception is PropertyAccessExceptionsException (1 errors)
    PropertyAccessExceptionsException (1 errors)
    org.springframework.beans.TypeMismatchException: Failed to convert property value of type [COM.ibm.db2.jdbc.DB2XADataSource] to required type [javax.sql.DataSource] for property 'dataSource'

    Please advice. Do I need to use some other Db2 datasource class?

    -scorchicks

  2. #2
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    The only thing that I can spot is that you are defining a COM.ibm.db2.jdbc.DB2BasicDataSource while the error message talks about COM.ibm.db2.jdbc.DB2XADataSource.
    Make sure Spring loads the appropriate XML configuration files and that the DB2 datasource which you are using does indeed implement the DataSource interface - it might offer a factory-method for getting an implementation of that interface.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  3. #3
    Join Date
    Nov 2006
    Posts
    4

    Default Error connecting to DB2

    I am using this to connect to DB2:

    <bean id="testDataSource" class="COM.ibm.db2.jdbc.DB2DataSource" destroy-method="close">
    <property name="serverName">
    <value>db2stg01.es.ssrb.com</value>
    </property>
    <property name="portNumber">
    <value>4245</value>
    </property>
    <property name="databaseName">
    <value>...</value>
    </property>
    <property name="user">
    <value>...</value>
    </property>
    <property name="password">
    <value>...</value>
    </property>
    </bean>

    I get this error:
    Could not get JDBC Connection; nested exception is COM.ibm.db2.jdbc.DB2Exception: [IBM][JDBC Driver] CLI0615E Error receiving from socket, server is not responding. SQLSTATE=08S01..

    I am sure that the serverName/portnumber I am using is correct. Am I missing something?




    Error Stack:
    org.springframework.jdbc.CannotGetJdbcConnectionEx ception: Could not get JDBC Connection; nested exception is COM.ibm.db2.jdbc.DB2Exception: [IBM][JDBC Driver] CLI0615E Error receiving from socket, server is not responding. SQLSTATE=08S01
    COM.ibm.db2.jdbc.DB2Exception: [IBM][JDBC Driver] CLI0615E Error receiving from socket, server is not responding. SQLSTATE=08S01
    at COM.ibm.db2.jdbc.net.SQLExceptionGenerator.throwRe ceiveError(SQLExceptionGenerator.java:457)
    at COM.ibm.db2.jdbc.net.DB2Request.receive(DB2Request .java:703)
    at COM.ibm.db2.jdbc.net.DB2Request.sendAndRecv(DB2Req uest.java:563)
    at COM.ibm.db2.jdbc.net.DB2Connection.SQLConnect(DB2C onnection.java:360)
    at COM.ibm.db2.jdbc.net.DB2Connection.SQLConnect(DB2C onnection.java:315)
    at COM.ibm.db2.jdbc.net.DB2Connection.create(DB2Conne ction.java:300)
    at COM.ibm.db2.jdbc.net.DB2Connection.<init>(DB2Conne ction.java:195)
    at COM.ibm.db2.jdbc.net.DB2ReusableConnection.<init>( DB2ReusableConnection.java:69)
    at COM.ibm.db2.jdbc.DB2PooledConnection.getConnection (DB2PooledConnection.java:201)
    at COM.ibm.db2.jdbc.DB2DataSource.getConnection(DB2Da taSource.java:129)
    at COM.ibm.db2.jdbc.DB2DataSource.getConnection(DB2Da taSource.java:97)
    at org.springframework.jdbc.datasource.DataSourceUtil s.doGetConnection(DataSourceUtils.java:112)
    at org.springframework.jdbc.datasource.DataSourceUtil s.getConnection(DataSourceUtils.java:77)
    at org.springframework.orm.ibatis.SqlMapClientTemplat e.execute(SqlMapClientTemplate.java:165)
    at org.springframework.orm.ibatis.SqlMapClientTemplat e.executeWithListResult(SqlMapClientTemplate.java: 190)
    at org.springframework.orm.ibatis.SqlMapClientTemplat e.queryForList(SqlMapClientTemplate.java:229)
    at com.ibm.samples.ClientDAOImpl.getClientInfo(Client DAOImpl.java:20)
    at com.ibm.samples.SimpleServlet.doGet(SimpleServlet. java:60)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet .java:853)
    at com.ibm.servlet.engine.webapp.StrictServletInstanc e.doService(ServletManager.java:827)
    at com.ibm.servlet.engine.webapp.StrictLifecycleServl et._service(StrictLifecycleServlet.java:159)
    at com.ibm.servlet.engine.webapp.IdleServletState.ser vice(StrictLifecycleServlet.java:286)
    at com.ibm.servlet.engine.webapp.StrictLifecycleServl et.service(StrictLifecycleServlet.java:106)
    at com.ibm.servlet.engine.webapp.ServletInstance.serv ice(ServletManager.java:472)
    at com.ibm.servlet.engine.webapp.ValidServletReferenc eState.dispatch(ServletManager.java:1012)
    at com.ibm.servlet.engine.webapp.ServletInstanceRefer ence.dispatch(ServletManager.java:913)
    at com.ibm.servlet.engine.webapp.WebAppRequestDispatc her.handleWebAppDispatch(WebAppRequestDispatcher.j ava:499)
    at com.ibm.servlet.engine.webapp.WebAppRequestDispatc her.dispatch(WebAppRequestDispatcher.java:278)
    at com.ibm.servlet.engine.webapp.WebAppRequestDispatc her.forward(WebAppRequestDispatcher.java:105)
    at com.ibm.servlet.engine.srt.WebAppInvoker.doForward (WebAppInvoker.java:67)
    at com.ibm.servlet.engine.srt.WebAppInvoker.handleInv ocationHook(WebAppInvoker.java:123)
    at com.ibm.servlet.engine.invocation.CachedInvocation .handleInvocation(CachedInvocation.java:67)
    at com.ibm.servlet.engine.invocation.CacheableInvocat ionContext.invoke(CacheableInvocationContext.java: 106)
    at com.ibm.servlet.engine.srp.ServletRequestProcessor .dispatchByURI(ServletRequestProcessor.java:125)
    at com.ibm.servlet.engine.oselistener.OSEListenerDisp atcher.service(OSEListener.java:315)
    at com.ibm.servlet.engine.http11.HttpConnection.handl eRequest(HttpConnection.java:60)
    at com.ibm.ws.http.HttpConnection.readAndHandleReques t(HttpConnection.java:313)
    at com.ibm.ws.http.HttpConnection.run(HttpConnection. java:242)
    at com.ibm.ws.util.CachedThread.run(ThreadPool.java:1 22)

  4. #4
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Seems that your configuration is not correct - you are using the wrong port/host. Check your jdbc driver docs to find the meaning of the code error.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  5. #5
    Join Date
    Aug 2004
    Location
    Burgas, Bulgaria
    Posts
    37

    Default

    I use something like this to talk to db2:
    Code:
      <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"
        lazy-init="true">
        <property name="poolPreparedStatements" value="true" />
        <property name="url" value="jdbc:db2://localhost:50000/HCA:driverType=4;currentSchema=DB2ADMIN;" />
        <property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver" />
        <property name="username" value="username" />
        <property name="password" value="password" />
      </bean>
    I use the DB2Driver for the driverClassName, and the commons dbcp for the dataSource. I've used spring's SingleConnectionDataSource as the dataSource as well. In any case, I avoid the dataSource provided by DB2 and have had success.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •