In fact, the main problem of connecting to the database in Java development is not how to writeCode, But find the driver package. Because there are too many JDBC driver packages and many names, some of them still need to be installed on the client to run.
In the project practice, JavaYou do not need to install the client:
I.Sqlserver:
Driver package:Sqljdbc. Jar
Instance:
String _ drivername = "com. Microsoft. sqlserver. JDBC. sqlserverdriver ";//Driver
String _ dburl = "JDBC: sqlserver: // 198.9.100.202: 1433; databasename = cctv_jdan ";//Address
String _ username = "sa ";// User Name
String _ userpwd = "1 ";// Password
II.DB2:
Driver package:Db2jcc. Jar,Db2jcc_license_cu.jar
Instance:
String _ drivername = "com. IBM. db2.jcc. db2driver ";//Driver
String _ dburl = "JDBC: DB2: // 198.9.100.202: 50000/jdan ";//Address
String _ username = "DBO ";// User Name
string _ userpwd =" password "; /// password
Note: DB2 is the most annoying because it requires license to find a genuine DB2 version. The installation package containsDb2jcc_license_cu.jar. In addition, the problem of the database character set may cause JavaProgramEncoding Error: "encoding not supported"
Solution:
1 , Replace the Sun JDK of the program IBM Of JDK ; (--- Of course, strong Not recommended ---)
2 , You can DB2 Set the encoding UTF-8 ;
3 Use the latest V8 fixpack12 The Db2jcc. Jar It can also be solved. You can download it from the DB2 official website.
III.Oracle:
Driver package:Ojdbc14.jar
Instance:
String _ drivername = "oracle. JDBC. Driver. oracledriver ";//Driver
String _ dburl = "JDBC: oracle: thin: @ 198.9.1.24: 1521: mam32 ";//Address
string _ username =" mam32sys "; /// User Name
string _ userpwd =" password "; /// password