java中jdbc链接数据库大全
经常因为链接字符串记不住或者记错的原因浪费时间,终于有时间把常用的总结出来,要用就简单了http://writeblog.csdn.net/Editor/FCKeditor/editor/images/smiley/msn/regular_smile.gif1、链接Sqlserver2000
[*] 驱动类
com.microsoft.jdbc.sqlserver.SQLServerDriver
[*]连接字符串
jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs
http://writeblog.csdn.net/Editor/FCKeditor/editor/images/smiley/msn/lightbulb.gif(pubs为数据库名,localhost为主机地址,若数据库在远程则为IP地址)
2、链接mysql
[*]驱动类
com.mysql.jdbc.Driver
[*]连接字符串
jdbc:mysql://localhost:3306/pubs
http://writeblog.csdn.net/Editor/FCKeditor/editor/images/smiley/msn/lightbulb.gif(pubs为数据库名,localhost为主机地址,若数据库在远程则为IP地址)
3、jdbc-odbc桥链接
[*]驱动类
sun.jdbc.odbc.JdbcOdbcDriver
[*]连接字符串
jdbc:odbc:dsnname
http://writeblog.csdn.net/Editor/FCKeditor/editor/images/smiley/msn/lightbulb.gif(dsnname为odbc数据源的名称)
4、链接Oracle
[*]驱动类:
oracle.jdbc.driver.OracleDriver
[*]链接字符串
jdbc:oracle:thin:@localhost:1521:ora9
http://writeblog.csdn.net/Editor/FCKeditor/editor/images/smiley/msn/lightbulb.gif(localhost为主机地址,若数据库,在远程则为IP地址其中“1521”为端口,“ora9”为sid )
5、连接DB2
[*]驱动类:
COM.ibm.db2.jdbc.app.DB2Driver
[*]连接字符串:
jdbc:db2://192.168.1.10/50000:rdb
http://writeblog.csdn.net/Editor/FCKeditor/editor/images/smiley/msn/lightbulb.gif(这里192.168.1.10为数据库所在服务器IP地址,而50000为DB2连接服务的端口号)
6、链接Sybase
[*]驱动类:
com.sybase.jdbc3.jdbc.SybDriver
[*]连接字符串:
jdbc:sybase:Tds:192.168.100.252:4500/myDB
http://writeblog.csdn.net/Editor/FCKeditor/editor/images/smiley/msn/lightbulb.gif(这里192.168.100.252为数据库所在服务器IP地址,而4500为Sybase连接服务的端口号myDB为数据库的名字)
7、链接Informix
[*]驱动类:
com.informix.jdbc.IfxDriver
[*]连接字符串:
jdbc:informix-sqli://192.168.100.252:1533/myDB:INFORMIXSERVER=myserver
http://writeblog.csdn.net/Editor/FCKeditor/editor/images/smiley/msn/lightbulb.gif(这里192.168.100.252为数据库所在服务器IP地址,而1533为Informix连接服务的端口号myDB为数据库的名字)
8、连接PostgreSQL
驱动类:
org.postgresql.Driver
链接字符串:
jdbc:postgresql://localhost/mydb
http://writeblog.csdn.net/Editor/FCKeditor/editor/images/smiley/msn/lightbulb.gif(localhost为主机地址,若数据库在远程则localhost为IP地址,mydb为数据库名称)
页:
[1]