JSP连接SQL2000的问题
系统是win2003的,JDK1.5,数据库是sqlserver2000,tomcat5.5
运行的时候报错如下:
The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
org.apache.jsp.index_jsp._jspService(org.apache.jsp.index_jsp:135)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
数据源名称没问题啊,我用的是JDBC-ODBC桥接,是否还需要下载JDBC驱动呢?还望各位高手指教!
程序主要部分如下:
Connection con=DriverManager.getConnection( "jdbc:odbc:sim ", " ", " ");
try
{
Statement sql=con.createStatement();
}
catch(SQLException e)
{}
//Connection con;
Statement sql;
ResultSet rs;
try
{
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
}
catch(ClassNotFoundException e)
{}
try
{
con=DriverManager.getConnection( "jdbc:odbc:sim ", " ", " "); //得到与数据库的连接
sql=con.createStatement();
rs=sql.executeQuery( "SELECT * FROM sim_table ");
out.print( " <table border> ");
out.print( " <tr> ");
out.print( " <th width=100> "+ "卡号 ");
out.print( " <th width=100> "+ "套餐种类 ");
out.print( " <th width=100> "+ "办卡时间 ");
out.print( " <th width=100> "+ "余额 ");
out.print( " <th width=100> "+ "归属地 ");
out.print( " </tr> ");
while(rs.next())
{
out.print( " <tr> ");
out.print( " <td> "+rs.getString( "sim_NUM ")+ " </td> ");
out.print( " <td> "+rs.getString( "type ")+ " </td> ");
out.print( " <td> "+rs.getString( "time ")+ " </td> ");
out.print( " <td> "+rs.getString( "balance ")+ " </td> ");
out.print( " <td> "+rs.getString( "locus ")+ " </td> ");
out.print( " </tr> ");
}
out.print( " </table> ");
con.close();
}
catch(SQLException e1)
{}
[解决办法]
是不是没把驱动放到相应目录?
[解决办法]
到微软公司网站上下载JDBC驱动程序包吧!然后放到TOMCAT的/command/lib目录下,或者放到应用网站的WEB-INF/lib下中!同时还要把这个JDBC驱动程序加入classpath环境变量中去,更多关于JSP开发方面的资料,万春IT技术开网(http://wcp.fh668.com)不错!不妨上去看一下!
[解决办法]
直接用Class.forName( "com.microsoft.jdbc.sqlserver.SQLServerDriver ").newInstance();
这个驱动吧,用JDBC-ODBC桥接,太烦,而且实际数据也中转了好几次,下个jdbc.sqlserver驱动吧
[解决办法]
使用桥接要配置数据源吧,没用过,直接用JDBC效率高
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html