主题:jsp连接数据库的问题
<%@ page contentType="text/html;charset=GB2312" %>
<%@ page import="java.sql.*" %>
<HTML>
<BODY>
<% Connection con;
Statement sql;
ResultSet rs;
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}
catch(ClassNotFoundException e)
{
out.print("类找不到!"+e+"; ");
}
try{
con=DriverManager.getConnection("jdbc:microsoft:sqlserver://192.168.0..1:1433;DatabaseName=MyWebDB","z","");
sql=con.createStatement();
rs=sql.executeQuery("SELECT * FROM tb1");
out.print("<Table Border>");
out.print("<TR><td colspan=8 align=center>用户数据</td></tr>");
out.print("<TR>");
out.print("<Td width=100 >"+"用户ID号");
out.print("<Td width=50 >"+"用户名");
out.print("</TR>");
while(rs.next())
{out.print("<TR>");
out.print("<TD >"+rs.getLong(1)+"</TD>");
out.print("<TD >"+rs.getString(2)+"</TD>");
out.print("</TR>") ;
}
out.print("</Table>");
con.close();
}
catch(SQLException e1)
{
out.print("SQL异常!");
out.print(e1);
}
%>
</BODY>
</HTML>
错误提示是:
类找不到!java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver; SQL异常!java.sql.SQLException: No suitable driver
是不是jdbc驱动的问题,可是jdbc我装了,各位高手伴我看看是什么问题
<%@ page import="java.sql.*" %>
<HTML>
<BODY>
<% Connection con;
Statement sql;
ResultSet rs;
try
{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
}
catch(ClassNotFoundException e)
{
out.print("类找不到!"+e+"; ");
}
try{
con=DriverManager.getConnection("jdbc:microsoft:sqlserver://192.168.0..1:1433;DatabaseName=MyWebDB","z","");
sql=con.createStatement();
rs=sql.executeQuery("SELECT * FROM tb1");
out.print("<Table Border>");
out.print("<TR><td colspan=8 align=center>用户数据</td></tr>");
out.print("<TR>");
out.print("<Td width=100 >"+"用户ID号");
out.print("<Td width=50 >"+"用户名");
out.print("</TR>");
while(rs.next())
{out.print("<TR>");
out.print("<TD >"+rs.getLong(1)+"</TD>");
out.print("<TD >"+rs.getString(2)+"</TD>");
out.print("</TR>") ;
}
out.print("</Table>");
con.close();
}
catch(SQLException e1)
{
out.print("SQL异常!");
out.print(e1);
}
%>
</BODY>
</HTML>
错误提示是:
类找不到!java.lang.ClassNotFoundException: com.microsoft.jdbc.sqlserver.SQLServerDriver; SQL异常!java.sql.SQLException: No suitable driver
是不是jdbc驱动的问题,可是jdbc我装了,各位高手伴我看看是什么问题