Summary of JDBC connections to the three mainstream database databases in Java (sqlserver, DB2, Oracle)

Source: Internet
Author: User

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

 

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.