JDBC各种数据库的连接的URL

来源:互联网 发布:想学电脑编程 编辑:程序博客网 时间:2024/05/17 01:09

由于使用了JDBC,各种数据库连接的方式是相同的,只是不同的数据库的连接URL不同。常见的数据库的连接URL见下表:

数据库 

连接URL 

说明

MySQL 

jdbc:mysql://locahost:3306/db 

默认端口为3306.粗体为连接时使用的数据库 模式。下同

Oracle 

jdbc:oracle:thin:@localhost:1521:db 

默认端口为1521

DB2 

jdbc:db2:localhost:6789/db 

默认端口为6789

PostgreSQL 

jdbc:postgresql://localhost:5432/db 

默认端口为5432 

Sysbase 

jdbc:jtds:sybase://localhost:2638/db 

默认端口为2638 

SQLServer 

jdbc:microsoft:sqlserver://localhost:1433;databaseName=db 

默认端口为1433

SQLServer2005 

jdbc:sqlserver://localhost:1433;databaseName=db 

默认端口为1433

1 0