JSP连接数据源的问题
系统是win2003的,JDK1.5,数据库是sqlserver2000,tomcat5.5
JSP运行的时候报错如下:
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)
{}
[解决办法]
驱动
[解决办法]
加个数据源名称啊!!
控制面版--> 管理工具--> 数据源(ODBC)
使单击 "用户 DSN "/ "系统 DSN "/ "文件 DSN "选项卡,
单击 SQL Server,然后单击 "完成 "按钮。
完成向 SQL Server 新建数据源向导中的步骤。
[解决办法]
驱动可加了 sqlserver三个驱动包
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html