talkinsky
发贴: 2
|
于 2005-03-27 21:50
在下写了一个连接sqlserver的jsp程序如下: <%@page contentType="text/html;charset=gb2312"%> <%@page pageEncoding="UTF-8"%> <%@page import="java.sql.*"%> <html> <head><title>JSP Page</title></head> <body> <% try{ Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance(); String url="jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=lyb"; String user="sa"; String password="12115891"; Connection conn= DriverManager.getConnection(url,user,password); Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE); String sql="select * from lyb"; ResultSet rs=stmt.executeQuery(sql); while(rs.next()) {%> 您的第一个字段内容为:<%=rs.getString(1)%> <%}%> <% conn.close(); }catch(Exception e){out.print;} %> </body> </html> 但是提示: java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver 可是我的数据库服务器经过测试可以连接到数据库。 请各位大虾们帮帮忙找出问题,谢谢!
|