JDBC连MSSQL server问题大大通常用
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
如果想连MSSQL SERVER上的数据库,谁能告诉我它的driver名称是什么?网上找也找不到
还有这个数据库的路径怎么写的?
谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢[百及子 (2-13 16:50, Long long ago)]
[ 传统版 |
sForum ][登录后回复]1楼
If really cannot found, try jdbc-odbc-bridgethough it is not that effecient...
but it is a solution[为什么爬? (2-13 16:55, Long long ago)]
[ 传统版 |
sForum ][登录后回复]2楼
(引用 为什么爬?:If really cannot found, try jdbc-odbc-bridgethough it is not that effecient... but it is a solution)好像不行啊java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified[百及子 (2-13 17:16, Long long ago)] [ 传统版 | sForum ][登录后回复]3楼
(引用 百及子:好像不行啊java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified)我用mysql的odbc没有问题, 请检查sql server的数据源及其权限
<%@ page import = "java.sql.*" %>
<%
String url = "jdbc:odbc:mysql";
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
try{
Class.forName(driver);
java.sql.Connection conn = DriverManager.getConnection(url,"wushilin","******");
Statement s = conn.createStatement();
s.executeUpdate("insert into test values('asdf')");
ResultSet rs = s.executeQuery("select * from test");
while(rs.next())
{
out.println(rs.getString(1)+"<br>");
}
rs.close();
s.close();
conn.close();
}
catch(Exception e)
{
System.err.println("Error");
}
%>
output:
test
test
test
asdf
asdf
asdf
asdf
[为什么爬? (2-13 18:45, Long long ago)]
[ 传统版 |
sForum ][登录后回复]4楼
(引用 为什么爬?:我用mysql的odbc没有问题, 请检查sql server的数据源及其权限 output: test test test asdf asdf asdf asdf ...)mysql是数据源[为什么爬? (2-13 18:45, Long long ago)] [ 传统版 | sForum ][登录后回复]5楼
(引用 为什么爬?:我用mysql的odbc没有问题, 请检查sql server的数据源及其权限 output: test test test asdf asdf asdf asdf ...)Note that jdbc-odbc bridge is embeded in jdk sincejdk1.3.0[为什么爬? (2-13 19:07, Long long ago)] [ 传统版 | sForum ][登录后回复]6楼
(引用 为什么爬?:Note that jdbc-odbc bridge is embeded in jdk sincejdk1.3.0)thanksbut i think i need to download ms sql jdbc driver instead[百及子 (2-13 19:20, Long long ago)] [ 传统版 | sForum ][登录后回复]7楼
http://www.microsoft.com/sql/downloads/default.aspsearch for "JDBC" and you will find the driver[逃课专家 (2-13 22:00, Long long ago)] [ 传统版 | sForum ][登录后回复]8楼