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
Type2:url forms such as: jdbc:db2:DBName, need to rely on local library files.
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: