JDBC Connection database Overview

Source: Internet
Author: User
Tags sybase

JDBC Connection database Overview
Common Methods for connecting to a database through JDBC are summarized as follows:

1. JDBC connection to DB2
Class. forname ("com.ibm.db2.jdbc.net. db2driver ");
String url = "JDBC: DB2: // dburl: Port/dbname"
CN = drivermanager. getconnection (URL, susr, spwd );

2. JDBC connection to Microsoft sqlserver (Microsoft)
Class. forname ("com. Microsoft. JDBC. sqlserver. sqlserverdriver ");
CN = drivermanager. getconnection ("JDBC: Microsoft: sqlserver: // dbserverip: 1433; databasename = Master", susr, spwd );

Iii. JDBC connection to Sybase (jconn2.jar)
Class. forname ("com. Sybase. jdbc2.jdbc. sybdriver ");
CN = drivermanager. getconnection ("JDBC: Sybase: TDS: dbserverip: 2638", susr, spwd );

4. JDBC connection to MySQL (Mm. mysql-3.0.2-bin.jar)
Class. forname ("org. gjt. Mm. MySQL. Driver ");
CN = drivermanager. getconnection ("JDBC: mysql: // dbserverip: 3306/mydatabasename", susr, spwd );

V. JDBC connection to PostgreSQL (pgjdbc2.jar)
Class. forname ("org. PostgreSQL. Driver ");
CN = drivermanager. getconnection ("JDBC: PostgreSQL: // dbserverip/mydatabasename", susr, spwd );

6. JDBC connection to Oracle (classes12.jar)
Class. forname ("oracle. JDBC. Driver. oracledriver ");
CN = drivermanager. getconnection ("JDBC: oracle: thin: @ mydbcomputernameorip: 1521: orcl", susr, spwd );

VII. JDBC connection to ODBC
Class. forname ("Sun. JDBC. ODBC. jdbcodbcdriver ");
Connection Cn = drivermanager. getconnection ("JDBC: ODBC:" + sdsn, susr, spwd );

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.