还是mssql的连接问题!!!
这个是我连接数据库的jsp文件报错结果javax.servlet.ServletException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:673)
org.apache.jsp.TMPiprg5f4xh0_jsp._jspService(TMPiprg5f4xh0_jsp.java:76)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
感觉像是说sa用户名和密码的问题导致连接不上,但是这是再我本机上测试的啊,用户名和密码我都设置的是sa,应该没有问题的啊,我把连接改成用odbc就ok
真晕。
这个是我的bean文件
package test;
import java.sql.*;
public class SQLBean
{
Connection con=null;
ResultSet rs=null;
//实例化,装载JDBC驱动程序
public SQLBean()
{
try{
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
}
catch(ClassNotFoundException e) {}
}
//返回查询后的数据集
public ResultSet executeQuery(String sql)
{
String url="jdbc:microsoft:sqlserver://nbdragon:1433;DatabaseName=test";
String username="sa";
String password="sa";
try{
con=DriverManager.getConnection(url,username,password);
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs=stmt.executeQuery(sql);
}
catch(SQLException e) {}
return rs;
}
//关闭数据库
public void closeDB()
{
try{
rs.close();
con.close();
}catch(SQLException e) {}
}
}
[此贴子已经被作者于2005-4-18 17:29:00编辑过]