JDBC string used to connect to various databases

Source: Internet
Author: User

The strings used to connect JDBC to various databases are similar. Here, I would like to sum up the notes.

Oracle
Driverclass: Oracle. JDBC. Driver. oracledriver
URL: JDBC: oracle: thin: @ 127.0.0.1: 1521: dbname
MySQL
Driverclass: COM. MySQL. JDBC. Driver

PS:Sometimes, the MySQL driver class will also see the use of Org. gjt. mm. mySQL. driver, org. gjt. mm. mySQL. the driver was an early driver name and was later renamed as COM. mySQL. JDBC. driver. com. mySQL. JDBC. driver. In the latest MySQL JDBC driver, org. gjt. mm. mySQL. driver, but in fact Org. gjt. mm. mySQL. the driver calls COM. mySQL. JDBC. driver, so there is no difference between the two drivers.
URL: JDBC: mysql: // localhost: 3306/mydb
DB2
Driverclass: COM. IBM. db2.jcc. db2driver
URL: JDBC: DB2: // 127.0.0.1: 50000/dbname
Sybase
Driverclass: COM. Sybase. JDBC. sybdriver
URL: JDBC: Sybase: TDS: localhost: 5007/dbname
PostgreSQL
Driverclass: org. PostgreSQL. Driver
URL: JDBC: PostgreSQL: // localhost/dbname
SQL Server2000
Driverclass: COM. Microsoft.JDBC. sqlserver. Sqlserverdriver
URL: JDBC:Microsoft:Sqlserver: // localhost: 1433; databasename = dbname
SQL server2005
Driverclass: COM. Microsoft.Sqlserver. JDBC. Sqlserverdriver
URL: JDBC: sqlserver: // localhost: 1433; databasename = dbname

PS:The driver of SQL Server 2005 differs from that of SQL Server. The following error occurs when an error occurs. Java. SQL. sqlexception: [Microsoft] [sqlserver JDBC driver] [sqlserver] The input table format data stream (TDS) Remote Process Call (RPC) protocol stream is incorrect. Parameter 1 (""): the data type 0x38 is unknown.

Below is a piece of JavaCodeTake SQL server2005 as an example:

 Package  Com. wanggc. jdbctest;  Import  Java. SQL. connection;  Import  Java. SQL. drivermanager;  Import  Java. SQL. resultset; Import  Java. SQL. sqlexception;  Import  Java. SQL. statement;  Public   Class  Sqlserver2012 {  /**  *  @ Param  ARGs  */      Public   Static   Void  Main (string [] ARGs) {connection Conn = Null  ; Statement stmt = Null  ; Resultset rs = Null  ;  Try  {Class. forname ( "Com. Microsoft. sqlserver. JDBC. sqlserverdriver" ); Conn = Drivermanager. getconnection ( "JDBC: sqlserver: // 192.168.1.172: 1433; databasename = eossample" , "Sa", "eos_123" );  //  Conn. setautocommit (false ); Stmt = Conn. createstatement (); RS = Stmt.exe cutequery ("select * From ac_application" );  While  (Rs. Next () {system. Out. println (Rs. getstring ( "Appname" ));}  //  Conn. Commit ();  Conn. Close ();} Catch  (Exception e) {e. printstacktrace ();}  Finally  {  Try  {  If (! Conn. isclosed () {conn. Close ();}  If (! Stmt. isclosed () {stmt. Close ();}  If (!Rs. isclosed () {Rs. Close ();}}  Catch  (Sqlexception e) {e. printstacktrace ();}}}} 

 

 

 

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.