JDBC conn http://snippets.dzone.com/posts/show/4925

   1  
2 1. 各种数据库的JDBC连接大全
3 2. Microsoft SQL Server series (6.5, 7.x and 2000) and Sybase 10
4 3.
5 4. JDBC Name: jTDS
6 5. URL: http://jtds.sourceforge.net/
7 6. Version: 0.5.1
8 7. Download URL: http://sourceforge.net/project/showfiles.php?group_id=33291
9 8.
10 9. 语法:
11 10. Class.forName("net.sourceforge.jtds.jdbc.Driver ");
12 11. Connection con = DriverManager.getConnection("jdbc:jtds:sqlserver://host:port/database","user","password");
13 12. or
14 13. Connection con = DriverManager.getConnection("jdbc:jtds:sybase://host:port/database","user","password");
15 14.
16 15. MySQL
17 16.
18 17. JDBC Name: Connector/J 3.0
19 18. URL: http://www.mysql.com/
20 19. Version: 3.0.8-stable
21 20. Download URL: http://www.mysql.com/downloads/api-jdbc-stable.html
22 21.
23 22. 语法:
24 23. Download URL: http://www.mysql.com/downloads/api-jdbc-stable.html
25 24.
26 25. 语法:
27 26. Class.forName("com.mysql.jdbc.Driver");
28 27. Connection con = DriverManager.getConnection("jdbc:mysql://host:port/database","user","password");
29 28.
30 29. Oracle
31 30.
32 31. JDBC Name: Connector/J 3.0
33 32. URL: http://otn.oracle.com/
34 33. Version: 3.0.8-stable
35 34. Download URL: http://otn.oracle.com/software/tech/java/sqlj_jdbc/content.html
36 35.
37 36. 语法:
38 37. Download URL: http://otn.oracle.com/software/tech/java/sqlj_jdbc/content.html
39 38.
40 39. 语法:
41 40. Class.forName("oracle.jdbc.driver.OracleDriver");
42 41. Connection con = DriverManager.getConnection("jdbc:oracle:thin:@host:port:databse","user","password");
43 42.
44 43. Sybase
45 44.
46 45. Driver: jConnect 4.5/5.5 (JDBC 2.0 请使用5.5)
47 46.
48 47. 语法:
49 48.
50 49. Class.forName("com.sybase.jdbc2.jdbc.SybDriver").newInstance();
51 50. DriverManager.getConnection("jdbc:sybase:Tds:IP地址:2638?ServiceName="+数据库名称,"账号","密码");
52 51.
53 52. Postgresql
54 53.
55 54. JDBC Name: PostgreSQL JDBC
56 55. URL: http://jdbc.postgresql.org/
57 56. Version: 7.3.3 build 110
58 57. Download URL: http://jdbc.postgresql.org/download.html
59 58.
60 59. 语法:
61 60. Download URL: http://jdbc.postgresql.org/download.html
62 61.
63 62. 语法:
64 63. Class.forName("org.postgresql.Driver");
65 64. Connection con=DriverManager.getConnection("jdbc:postgresql://host:port/database","user","password");
66 65.
67 66. IBM AS400主机在用的JDBC语法
68 67.
69 68. 有装V4R4以上版本的Client Access Express
70 69. 可以在C:Program FilesIBMClient Accessjt400lib
71 70. 找到 driver 档案 jt400.zip,并更改扩展名成为 jt400.jar
72 71.
73 72. 语法语法:
74 73. Class.forName("net.sourceforge.jtds.jdbc.Driver ");
75 74. Connection con = DriverManager.getConnection("jdbc:jtds:sqlserver://host:port/database","user","password");
76 75. or
77 76. Connection con = DriverManager.getConnection("jdbc:jtds:sybase://host:port/database","user","password");
78 77.
79 78. MySQL
80 79.
81 80. JDBC Name: Connector/J 3.0
82 81. URL: http://www.mysql.com/
83 82. Version: 3.0.8-stable
84 83. Download URL: http://www.mysql.com/downloads/api-jdbc-stable.html
85 84.
86 85. 语法:
87 86. Download URL: http://www.mysql.com/downloads/api-jdbc-stable.html
88 87.
89 88. 语法:
90 89. Class.forName("com.mysql.jdbc.Driver");
91 90. Connection con = DriverManager.getConnection("jdbc:mysql://host:port/database","user","password");
92 91.
93 92. Oracle
94 93.
95 94. JDBC Name: Connector/J 3.0
96 95. URL: http://otn.oracle.com/
97 96. Version: 3.0.8-stable
98 97. Download URL: http://otn.oracle.com/software/tech/java/sqlj_jdbc/content.html
99 98.
100 99. 语法:
101 100. Download URL: http://otn.oracle.com/software/tech/java/sqlj_jdbc/content.html
102 101.
103 102. 语法:
104 103. Class.forName("oracle.jdbc.driver.OracleDriver");
105 104. Connection con = DriverManager.getConnection("jdbc:oracle:thin:@host:port:databse","user","password");
106 105.
107 106. Sybase
108 107.
109 108. Driver: jConnect 4.5/5.5 (JDBC 2.0 请使用5.5)
110 109.
111 110. 语法:
112 111.
113 112. Class.forName("com.sybase.jdbc2.jdbc.SybDriver").newInstance();
114 113. DriverManager.getConnection("jdbc:sybase:Tds:IP地址:2638?ServiceName="+数据库名称,"账号","密码");
115 114.
116 115. Postgresql
117 116.
118 117. JDBC Name: PostgreSQL JDBC
119 118. URL: http://jdbc.postgresql.org/
120 119. Version: 7.3.3 build 110
121 120. Download URL: http://jdbc.postgresql.org/download.html
122 121.
123 122. 语法:
124 123. Download URL: http://jdbc.postgresql.org/download.html
125 124.
126 125. 语法:
127 126. Class.forName("org.postgresql.Driver");
128 127. Connection con=DriverManager.getConnection("jdbc:postgresql://host:port/database","user","password");
129 128.
130 129. IBM AS400主机在用的JDBC语法
131 130.
132 131. 有装V4R4以上版本的Client Access Express
133 132. 可以在C:Program FilesIBMClient Accessjt400lib
134 133. 找到 driver 档案 jt400.zip,并更改扩展名成为 jt400.jar
135 134.
136 135. 语法
137 136. java.sql.DriverManager.registerDriver (new com.ibm.as400.access.AS400JDBCDriver ());
138 137. Class.forName("com.ibm.as400.access.AS400JDBCConnection");
139 138. con = DriverManager.getConnection("jdbc:as400://IP","user","passwor");
140 139.
141 140. 1Oracle8/8i/9i数据库(thin模式)
142 141. Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
143 142. String url="jdbc:oracle:thin:@localhost:1521:orcl"; //orcl为数据库的SID
144 143. String user="test";
145 144. String password="test";
146 145. Connection conn= DriverManager.getConnection(url,user,password);
147 146. 2DB2数据库
148 147. Class.forName("com.ibm.db2.jdbc.app.DB2Driver ").newInstance();
149 148. String url="jdbc:db2://localhost:5000/sample"; //sample为你的数据库名
150 149. String user="admin";
151 150. String password="";
152 151. Connection conn= DriverManager.getConnection(url,user,password);
153 152. 3Sql Server7.0/2000数据库
154 153. Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
155 154. String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=mydb";
156 155. //mydb为数据库
157 156. String user="sa";
158 157. String password="";
159 158. Connection conn= DriverManager.getConnection(url,user,password);
160 159. 4Sybase数据库
161 160. Class.forName("com.sybase.jdbc.SybDriver").newInstance();
162 161. String url =" jdbc:sybase:Tds:localhost:5007/myDB";//myDB为你的数据库名
163 162. Properties sysProps = System.getProperties();
164 163. SysProps.put("user","userid");
165 164. SysProps.put("password","user_password");
166 165. Connection conn= DriverManager.getConnection(url, SysProps);
167 166. 5Informix数据库
168 167. Class.forName("com.informix.jdbc.IfxDriver").newInstance();
169 168. String url = "jdbc:informix-sqli://123.45.67.89:1533/myDB:INFORMIXSERVER=myserver;
170 169. user=testuser;password=testpassword"; //myDB为数据库名
171 170. Connection conn= DriverManager.getConnection(url);
172 171. 6MySQL数据库
173 172. Class.forName("org.gjt.mm.mysql.Driver").newInstance();
174 173. String url ="jdbc:mysql://localhost/myDB?user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1"
175 174. //myDB为数据库名
176 175. Connection conn= DriverManager.getConnection(url);
177 176. 7PostgreSQL数据库
178 177. Class.forName("org.postgresql.Driver").newInstance();
179 178. String url ="jdbc:postgresql://localhost/myDB" //myDB为数据库名
180 179. String user="myuser";
181 180. String password="mypassword";
182 181. Connection conn= DriverManager.getConnection(url,user,password);
183 182. 8.access数据库直连用ODBC
184 183. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver") ;
185 184. String url="jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ="+application.getRealPath("/Data/ReportDemo.mdb");
186 185. Connection conn = DriverManager.getConnection(url,"","");
187 186. Statement stmtNew=conn.createStatement() ;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值