JDBC Connection DB2 time error Unsatisfiedlinkerror:

Source: Internet
Author: User
Tags db2

After I downgraded from Win8 to Win7, I ran the code and found an error:

Com.ibm.db2.jcc.am.SqlException: [jcc][10389][12245][4.19.26] loaded into native library db2jcct2, Java.lang.UnsatisfiedLinkError:no Db2jcct2 in Java.library.path failure

Strange, the re-installation of the system was clearly good, how can not now?

Google has learned that it is called the local dynamic link library. But why would you call something local? General even the database is not the URL plus the driver is OK?

Continue Google, the original is connected DB2 and Type2, Type4, and so on, Type2 way need to call the local link library, and Type4 do not need.

In this way, basically the cause of the problem is located, and then look at their own datasource configuration, found

Hikaridatasource ds = new Hikaridatasource ();d s.setdatasourceclassname ("Com.ibm.db2.jcc.DB2DataSource"); String Jdbcurl = String.Format ("jdbc:db2://%s:%s/%s", Dbip, Dbport, dbName); Logger.debug ("Parse jdbcurl:{}", Jdbcurl); Ds.setjdbcurl (Jdbcurl);

which

Jdbcurl in fact already is Type4 this form, can only doubt whether because set up the

Ds.setdatasourceclassname ("Com.ibm.db2.jcc.DB2DataSource");

Change the setting Datasourceclassname to

Ds.setdriverclassname ("Com.ibm.db2.jcc.DB2Driver");//both Type2 and Type4;

At run OK.


Summary: The JDBC connection DB2 is mainly in two different ways

    1. Type2:url forms such as: jdbc:db2:DBName, need to rely on local library files.

    2. Type4:url forms such as: Jdbc:db2://ip:port/dbname, and Type2 form of the main difference is more ip/port this direct form, this is pure Java implementation, without relying on local library files


Refer to the differences between connecting DB2 using Type2 and Type4 methods

JDBC Connection DB2 time error Unsatisfiedlinkerror:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.