14

I try to use jboss-seam with a db2 database, the following error occurs

com.ibm.db2.jcc.a.SqlException: [jcc][10389][12245][3.52.95] while loading the native 
library   db2jcct2, java.lang.UnsatisfiedLinkError: no db2jcct2 in java.library.path  
an error occurred ERRORCODE=-4472, SQLSTATE=null

I tried setting -Djava.library.path=/opt/IBM/db2/V9.5/lib64 as well as

-Djava.library.path=/opt/IBM/db2/V9.5/lib32

Both paths include libdb2jcct2.so

I also tried to set LD_LIBRARY_PATH with no effect.

OS is MacOs

EDIT I also tried to use a JDBC4 driver , db2jcc4.jar since jdbc4 drivers shouldn't rely on native libs.

Pascal Thivent
  • 562,542
  • 136
  • 1,062
  • 1,124
stacker
  • 68,052
  • 28
  • 140
  • 210

6 Answers6

30

The IBM Data Server Driver for JDBC and SQLJ includes both Type 2 and Type 4 JDBC drivers. Please check the following:

1) Make sure the driver is in your classpath: db2jcc.jar. Alternatively you can use the JDBC4 driver (db2jcc4.jar), but don't put both in the classpath.

2) Make sure that you're specifying the JCC driver (com.ibm.db2.jcc.DB2Driver) in your app configuration.

3) Use a Type-4 URL like jdbc:db2://server:port/database. If you specify a Type-2 URL like jdbc:db2:database then the driver will start looking for native libraries.

Ian Bjorhovde
  • 10,916
  • 1
  • 28
  • 25
2

Have you tried setting DYLD_LIBRARY_PATH too? Might be worth a shot.

dogbane
  • 266,786
  • 75
  • 396
  • 414
2

From the path, this looks a linux /unix platform. Try running strace/truss to see which directories are getting opened for library.

Jayan
  • 18,003
  • 15
  • 89
  • 143
  • 2
    +1 good hint, for the records the tool on a mac is called dtrace. dtrace -n 'syscall::open*:entry { printf("%s %s",execname,copyinstr(arg0)); }' – stacker Oct 18 '10 at 19:21
2

Append a "driverType=4;" to your URL.

1

I couldn't find a clear example anywhere, so I'm pasting my solution here. What fixed me up was adding a xa-datasource-property of "DriverType" value "4".

            <xa-datasource jndi-name="java:/DB2DataSource" pool-name="DB2DataSource" enabled="true" use-ccm="true">
                <xa-datasource-property name="ServerName">
                    my.server.com
                </xa-datasource-property>
                <xa-datasource-property name="DatabaseName">
                    SAMBLEDB
                </xa-datasource-property>
                <xa-datasource-property name="PortNumber">
                    50000
                </xa-datasource-property>
                <xa-datasource-property name="DriverType">
                    4
                </xa-datasource-property>
                <driver>ibmdb2</driver>
                <xa-pool>
                    <is-same-rm-override>false</is-same-rm-override>
                </xa-pool>
                <security>
                    <user-name>username</user-name>
                    <password>supersecret</password>
                </security>
                <recovery>
                    <recover-plugin class-name="org.jboss.jca.core.recovery.ConfigurableRecoveryPlugin"/>
                </recovery>
                <validation>
                    <valid-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2ValidConnectionChecker"/>
                    <background-validation>true</background-validation>
                    <stale-connection-checker class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2StaleConnectionChecker"/>
                    <exception-sorter class-name="org.jboss.jca.adapters.jdbc.extensions.db2.DB2ExceptionSorter"/>
                </validation>

            </xa-datasource>
Revoman
  • 222
  • 2
  • 6
-1

If the java.library.path (assigned using LD_LIBRARY_PATH env. variable) is wrong you should actually get something like: "failure in load of t2 native library".

You can check the java.library.path to se if the path is included like this.

System.out.println(System.getProperty("java.library.path"));

Could you be missing another jar like db2jcc_license_cu.jar

Maybe post your classpath. You can get it by reading the property java.class.path from the coide (like above).

Fedearne
  • 7,049
  • 4
  • 27
  • 31