DB2 JDBC connection

xiaoxiao2021-03-06  99

1: If the database is DB2, you have to find the username of the table, such as, TestTable this table, I am built through the system login, for lixc.testtable; I use query The user is admin, if you just write select * from testtable, DB2 is just the default lookup admin.testtable, this table does not exist, so it should be written as: select * from lixc.testtable 2: If you connect the database's URL and DRIVERNAME is read by profile * .properties, you should pay attention to: such as DriverManager: com.ibm.db2.jcc.db2driver, if there is a space behind it, you may appear when you run in Java, COM / IBM / DB2 / JCC / DB2DRIVER This Class file cannot be found. I have encountered this situation, if it is in Class.Forname ("drivername"). NewInstance (); test success, but read the configuration file class.forname (driverstr) .newinstance (); is reported. Later, remove the space behind the configuration file, the program is running successfully.

DB2 JDBC connection method: 1. Configure db2jcc.jar and db2jcc_license_cu.jar under the environment variable ClassPath.

2. Copy DB2JCC.JAR and DB2JCC_LICENSE_CU.jar under the web-inf / lib packet under the project you use.

3. JDBC URL: JDBC: DB2: // Tdurden: 50000 / Sample (Where tdurden is The Machine The DB2 Database Server Resides On and where sample is the database instance - 50000 is The default db2 port to connect to)

4. Driver Class Field: com.ibm.db2.jcc.db2driver

5. Add A Valid UserName and Password In The UserName and Password Fields.

转载请注明原文地址:https://www.9cbs.com/read-97504.html

New Post(0)