求救求救~~~~~~~~~
package jxc;
/**
* <p> Title: jxc demo </p>
* <p> Description: </p>
* <p> Copyright: Copyright (c) 2003 </p>
* <p> Company: </p>
* @author cwx
* @version 1.0
*/
import java.sql.*;
public class ConnectionManager {
public ConnectionManager() {
}
static public Connection getConnection(){
try{
//使用用来连接ODBC数据源的JDBC驱动,以连接到Access数据库
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
//DBQ参数用来指定Access数据库所在的位置,读者需要把它改为自己机器上的实际路径
Connection conn = DriverManager.getConnection( "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)}; "+
"DBQ=C:\\cwx\\books\\jxc\\jxc\\WEB-INF\\db.mdb ");
return conn;
}
catch(
java.lang.ClassNotFoundException e){
System.err.print( "get connection error! ");
System.err.print(e);
}
catch(
java.sql.SQLException e){
System.err.print( "get connection error! ");
System.err.print(e);
}
//出现错误,返回null
return null;
}
}
上面这段是一个jbuilder进销存管理系统中连接数据库access的代码!
我现在要改连接sql server 2000请问哪个专家能帮我指点下 说下哪些地方怎么改!!
谢谢!!!
------解决方案-------------------- <%@ page contentType= "text/html; charset=gb2312 " language= "java " import= "java.sql.* "%>
<html>
<body>
以下是从Ms SQL Server2000数据库读取的数据: <hr>
<table border=1>
<tr> <td> id </td> <td> 书名 </td> <td> 出版社 </td> <td> 价格 </td> </tr>
<%
//注意黑体字
Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ").newInstance();
Connection con=java.sql.DriverManager.getConnection( "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=books ", "sa ", " ");
Statement stmt=con.createStatement();
ResultSet rst=stmt.executeQuery( "select * from book ");
while(rst.next())
{
out.println( " <tr> ");
out.println( " <td> "+rst.getString( "bookId ")+ " </td> ");