DB2 and JDBC installation and deployment

Source: Internet
Author: User

During the installation and JDBC development of DB2, you may encounter some common problems and make a record to be noted:

1. License

Whether the DB2 version is genuine or not depends on the license, but there is no prompt during the installation process. License installation:

Db2licm-A [path]/db2ese. Lic

If the license is incorrect, the biggest impact is that the database cannot provide services to servers other than the local server. This is a fatal issue. Who installed DB2 for their own purposes? Of course, you can also play it yourself. You must pay attention to the following question:

2. app and net

JDBC type2 and type3 are similar connection methods. One is a local application and the other is a remote application.

Main Code of type2:
Class. forname ("com. IBM. db2.jdbc. App. db2driver";). newinstance ();
Connection c = drivermanager. getconnection ("JDBC: DB2: // [localdbname]", "[user]", "[Password]");

Type 2 JDBC driver, which uses the help of the DB2 local client library to establish a connection with the DB2 local database or remote database (catalog the remote database locally in advance ). Therefore, we must deploy the DB2 local client library on the machine where the application system is located, which may be one of its biggest shortcomings.
Main Code of type3:
Class. forname ("com.ibm.db2.jdbc.net. db2driver";). newinstance ();
Connection c = drivermanager. getconnection ("JDBC: DB2: // [serverip]: [port default: 6789]/[dbname]", "[user]", "[Password]");

Note that the port number here is the port number that the remote client gives us, not the database port number 50000.

Type 3 JDBC driver, which establishes a connection with the DB2 remote database by communicating with a machine that has deployed the DB2 local client library.

Note: If you do not have a license, remote connection may become unavailable.

3. codePage Error

If the remote connection system differs from the local code, the code page may occur. The following message is displayed:

Sql0332n there is no available conversion
The source code page "1386" to the target code
Page "819". Reason code "1". sqlstate = 57017

Codeset is specified as GBK when the database is created
The codePage of this database is 1386.

In the AIX system, the default codePage of DB2 is 819.
Because the connected client and the database codePage must be consistent
Therefore, you can obtain the codePage of the corresponding database through DB2 get dB CFG for dbname.
Then set db2codepage through db2set
Takes effect after database restart


Db2set db2codepage = 819

DB2 terminate

Appendix: codePage code page list

Conversion between any of the following codepages is provided.

37 (= x0025) ebcdic us einglsh
273 (= x0111) ebcdic German
277 (= x0115) ebcdic Danish/Norwegian
278 (= x0116) ebcdic Finnish/Swedish
280 (= x0118) ebcdic Italian
284 (= x011c) ebcdic Spanish
285 (= x011d) ebcdic UK English
297 (= x0129) ebcdic French
300 (= x012c) ebcdic Japan DBCS
301 (= x012d) Japanese PC DBCS
420 (= x01a4) ebcdic Arabic
424 (= x01a8) ebcdic Arabic
437 (= x01b5) PC-ASCII us
500 (= x01f4) ebcdic International
803 (= x0323) Hebrew set
813 (= x032d) ISO8859-7 Greek
819 (= x0333) ISO8859-1 Western European
833 (= x0341) IBM-833: Korean
834 (= x0342) IBM-834: Korean host DBCS
835 (= x0343) ebcdic traditional Chinese DBCS
836 (= x0344) ebcdic Simplified Chinese sbcs
838 (= x0346) ebcdic Thai sbcs
850 (= x0352) ISO8859-1 Western European
852 (= x0354) PC-ASCII Eastern European
855 (= x0357) PC-ASCII Cyrillic
856 (= x0358) PC-ASCII Hebrew
857 (= x0359) PC-ASCII Turkish
858 (= x035a) PC-ASCII Western European with Euro
860 (= x035c) PC-ASCII Portuguese
861 (= x035d) PC-ASCII Icelandic
862 (= x035e) PC-ASCII Hebrew
863 (= x035f) PC-ASCII Canadian French
864 (= x0360) PC-ASCII Arabic
865 (= x0361) PC-ASCII Scandinavian
866 (= x0133) PC-ASCII Cyrillic #2
868 (= x0364) PC-ASCII Urdu
869 (= x0365) PC-ASCII Greek
870 (= x0366) ebcdic Eastern Europe
871 (= x0367) ebcdic Icelandic
872 (= x0368) PC-ASCII Cyrillic with Euro
874 (= x036a) PC-ASCII Thai sbcs
875 (= x036b) ebcdic Greek
880 (= x0370) ebcdic Cyrillic
891 (= x037b) IBM-891: Korean
897 (= x0381) PC-ASCII Japan data sbcs
903 (= x0387) PC Simplified Chinese sbcs
904 (= x0388) PC traditional Chinese data-sbcs
912 (= x0390) ISO8859-2 Eastern European
915 (= x0393) ISO8859-5 Cyrillic
916 (= x0394) ISO8859-8 Hebrew
918 (= x0396) ebcdic Urdu
920 (= x0398) ISO8859-9 Turkish
921 (= x0399) ISO Baltic
922 (= x039a) ISO Estonian
923 (= x039b) ISO8859-15 Western Europe with Euro (Latin 9)
924 (= x039c) ebcdic Western Europe with Euro
927 (= x039f) PC traditional Chinese DBCS
928 (= x03a0) PC Simplified Chinese DBCS
930 (= x03a2) ebcdic Japanese Katakana/Kanji mixed
932 (= x03a4) Japanese OS/2
933 (= x03a5) ebcdic Korean mixed
935 (= x03a7) ebcdic Simplified Chinese mixed
937 (= x03a9) ebcdic traditional Chinese mixed
939 (= x03ab) ebcdic Japanese Latin/Kanji mixed
941 (= x03ad) Japan pc dbcs-for Open Systems
942 (= x03ae) Japanese PC Data mixed-extended sbcs
943 (= x03af) Japanese PC mixed-for Open Systems
944 (= x03bo) Korean PC Data mixed-extended sbcs
946 (= x03b2) Simplified Chinese PC Data mixed-extended sbcs
947 (= x03b3) PC traditional Chinese DBCS
948 (= x03b4) PC traditional Chinese mixed-extended sbcs
949 (= x03b5) PC Korean mixed-Ks code
950 (= x03b6) PC traditional Chinese mixed-big5
951 (= x03b7) PC Korean DBCS-Ks code
970 (= x03ca) EUC Korean
1004 (= x03ec) PC Data Latin1
1006 (= x03ee) ISO Urdu
1008 (= x03f0) ASCII Arabic 8-bit ISO
1025 (= x0401) ebcdic Cyrillic
1026 (= x0402) ebcdic Turkish
1027 (= x0403) ebcdic Japan Latin
1040 (= x0410) IBM-1040: Korean
1041 (= x0411) Japan PC-extended sbcs
1042 (= x0412) PC Simplified Chinese-extended sbcs
1043 (= x0413) PC traditional Chinese-extended sbcs
1046 (= x0416) PC-ASCII Arabic
1047 (= x0417) IBM-1047: Western European
1051 (= x041b) ASCII roman8 for HP Western European
1088 (= x0440) PC Korean sbcs-Ks code
1089 (= x0441) ISO8859-6 Arabic
1097 (= x0449) ebcdic Farsi
1098 (= x044a) PC-ASCII Farsi
1112 (= x0458) ebcdic Baltic (Latvian/Lithuanian)
1114 (= x045a) PC traditional Chinese-BIG 5 sbcs
1115 (= x045b) PC Simplified Chinese sbcs
1122 (= x0462) ebcdic Estonian
1123 (= x0463) ebcdic Ukrainian
1124 (= x0464) UNIX-ASCII Ukrainian
1131 (= x046b) PC-ASCII Belarus
1140 (= x0474) ebcdic USA, with Euro (like 037)
1141 (= x0475) ebcdic Austria, Germany, with Euro (like 273)
1142 (= x0476) ebcdic Denmark, Norway, with Euro (like 277)
1143 (= x0477) ebcdic Finland, Sweden, with Euro (like 278)
1144 (= x0478) ebcdic Italy, with Euro (like 280)
1145 (= x0479) ebcdic Spain, with Euro (like 284)
1146 (= x047a) ebcdic UK, with Euro (like 285)
1147 (= x047b) ebcdic France, with Euro (like 297)
1148 (= x047c) ebcdic International, with Euro (like 500)
1149 (= x047d) ebcdic Iceland, with Euro (like 871)
1200 (= x04b0) Unicode-UCS-2
1208 (= x04b8) Unicode-UTF-8
Windows-Eastern European 1250 (= x04e2)
1251 (= x04e3) Windows-Cyrillic
Windows-Western European 1252 (= x04e4)
1253 (= x04e5) Windows-Greek
1254 (= x04e6) Windows-Turkish
1255 (= x04e7) Windows-Hebrew
1256 (= x04e8) Windows-Arabic
1257 (= x04e9) Windows-Baltic Rim
1275 (= x04fb) Apple-Western European
1280 (= x0500) Apple-Greek
1281 (= x0501) Apple-Turkish
1282 (= x0502) Apple-Eastern European
1283 (= x0503) Apple-Cyrillic
1284 (= x0504) IBM-504: Eastern European
1285 (= x0505) IBM-505: Eastern European
1363 (= x0553) Windows Korean PC mixed including 11,172 full hangul
1364 (= x0554) Korean host mixed extended including 11,172 full hangul
1380 (= x0564) PC Simplified Chinese DBCS
1381 (= x0565) PC Simplified Chinese mixed
1383 (= x0567) EUC Simplified Chinese mixed
1386 (= x056a) PC Simplified Chinese data GBK mixed
1388 (= x056c) DBCS host Simplified Chinese data GBK mixed
5346 (= x14e2) Windows-Eastern European with Euro (like 1250)
5347 (= x14e3) Windows-Cyrillic with Euro (like 1251)
5348 (= x14e4) Windows-Western European with Euro (like 1252)
5349 (= x14e5) Windows-Greek with Euro (like 1253)
5350 (= x14e6) Windows-Turkish with Euro (like 1254)
5351 (= x14e7) Windows-Hebrew with Euro (like 1255)
5352 (= x14e8) Windows-Arabic with Euro (like 1256)
5353 (= x14e9) Windows-Baltic rim with Euro (like 1257)
5354 (= x14ea) 'windows-Vietnamese with Euro (like 1258)

4. code encoding

When compiling Java code, you must also consider whether the compilation encoding matches the database encoding. Generally, if the hard encoding of Chinese characters does not exist in the code, there will be no problem. However, if there is hard encoding, you need to consider whether the information written into the database can be properly identified without causing garbled characters. The solution is similar to the preceding DB2 get dB CFG for dbname to view the encoding type of the database. Make Java compilation Code consistent with it.

5. System User Permissions

After DB2 is installed, by default, two users can have DB2 management permissions: Administrator and db2admin. If you use another user to log on to Windows, you cannot perform configuration management on DB2 without setting it. You can also manage DB2 by granting the user permissions of the db2admin group to other system users.

6. JDBC driver

If you install db2.on the installation directory of db2, db2java.zip1_db2jcc.jar?common.jar=sqlj.zip and db2fs. jar will be displayed. These are the best stuff IBM has given to Java enthusiasts. Do not look for it elsewhere. Here is the most consistent Lib. Among them, db2java.zip is the package for jdbctype2 and type3. You can change the name to db2java. jar and add it to our project. JDBC type4 is supported in db2jcc. jar. The type4 driver is a Java-only JDBC driver, which is directly connected to the database server. The implementation package name is com. IBM. db2.jcc. db2driver.

If the developer is not the DB2 installer, the corresponding JDBC driver should be obtained after the DB2 version is clarified.





Write so much first. If you have time, try again.

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.