Java connection string URL for various databases

Source: Internet
Author: User
Tags informix mssqlserver sybase

// JDBC-ODBC Bridging Mode
Class. forname ("Sun. JDBC. ODBC. jdbcodbcdriver ");
Drivermanager. getconnection ("JDBC: ODBC: Test", user, PWD); // test indicates the name of the configured ODBC data source.
You can use

// SQL2000 connection method use MSSQLServer. jar package JDBC direct connection driver connection
Class. forname ("com. Microsoft. JDBC. sqlserver. sqlserverdriver ");
Drivermanager. getconnection ("JDBC: Microsoft: sqlserver: // localhost: 1433; databasename = News", user, PWD );

// Sql2005 uses the sqljdbc. jar package to connect to the JDBC directly connected driver
Class. forname ("com. Microsoft. sqlserver. JDBC. sqlserverdriver ");
Drivermanager. getconnection ("JDBC: sqlserver: // localhost; database = News", user, PWD );

You need to modify the configuration of sqlserver 2005 (Configuration tool ----> Configuration Management -----> sqlexpress protocol ---> ip address ----> TCP port is set to 1433)
If the TCP/IP connection to the host fails, configure the following: configuration tool ---> SQL Server peripheral application configurator ----> service and connection peripheral application configurator -----> MSSQLServer ----> remote connection ----> select local connection and remote connection to use TCP/IP

MySQL
Class. forname ("org. gjt. Mm. MySQL. Driver"); // This is a string of the old version. Currently, it is com. MySQL. JDBC. Driver.
Drivermanager. getconnection ("JDBC: mysql: // mydbcomputernameorip: 3306/mydatabasename", user, PWD );

PostgreSQL
Class. forname ("org. PostgreSQL. Driver ");
Drivermanager. getconnection ("JDBC: PostgreSQL: // mydbcomputernameorip/mydatabasename", user, PWD );

Oracle
Class. forname ("oracle. JDBC. Driver. oracledriver ");
Drivermanager. getconnection ("JDBC: oracle: thin: @ mydbcomputernameorip: 1521: orcl", user, PWD );

Sybase
Class. forname ("com. Sybase. jdbc2.jdbc. sybdriver ");
Drivermanager. getconnection ("JDBC: Sybase: TDS: mydbcomputernameorip: 2638", user, PWD );
// (Default-username/password: "dba"/"SQL ")

DB2
Class. forname ("com.ibm.db2.jdbc.net. db2driver ");
String url = "JDBC: DB2: // 192.9.200.108: 6789/sample"
Drivermanager. getconnection (URL, susr, spwd );

PostgreSQL
Class. forname ("org. PostgreSQL. Driver ");
Connection con = drivermanager. getconnection ("JDBC: PostgreSQL: // host: Port/Database", "user", "password ");


JDBC syntax used by the IBM as400 host
Java. SQL. drivermanager. registerdriver (new COM. IBM. as400.access. as400jdbcdriver ());
Class. forname ("com. IBM. as400.access. as400jdbcconnection ");
Drivermanager. getconnection ("JDBC: as400: // ip", "user", "password ");

Informix
Class. forname ("com. Informix. JDBC. ifxdriver"). newinstance ();
String url = "JDBC: Informix-sqli: // 123.45.67.89: 1533/testdb: informixserver = myserver;
User = testuser; Password = testpassword ";

SAP DB
Class. forname ("com. sap. dbtech. JDBC. driversapdb ");
Java. SQL. Connection connection = java. SQL. drivermanager. getconnection ("JDBC: sapdb: //" + host + "/" + database_name, user_name, password)

HSQLDB
URL: Driver: org. HSQLDB. jdbcdriver
There are four connection methods:
Con-STR (memory): JDBC: HSQLDB.
Con-STR (local): JDBC: HSQLDB:/path/to/The/DB/Dir
Con-STR (HTTP): JDBC: HSQLDB: http: // dbsrv
Con-STR (hsql): JDBC: HSQLDB: hsql: // dbsrv

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.