| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1453 人关注过本帖
标题:求教jsp与access数据库连接问题
只看楼主 加入收藏
np000
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2009-12-2
收藏
 问题点数:0 回复次数:3 
求教jsp与access数据库连接问题
description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
    org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:522)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
    org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:852)
    org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
    org.apache.jsp.access_jsp._jspService(access_jsp.java:150)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

java.sql.SQLException: [Microsoft][ODBC 驱动程序管理器] 未发现数据源名称并且未指定默认驱动程序
    sun.jdbc.odbc.JdbcOdbc.createSQLException(Unknown Source)
    sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
    sun.jdbc.odbc.JdbcOdbc.SQLDriverConnect(Unknown Source)
    sun.jdbc.odbc.JdbcOdbcConnection.initialize(Unknown Source)
    sun.jdbc.odbc.JdbcOdbcDriver.connect(Unknown Source)
    java.sql.DriverManager.getConnection(Unknown Source)
    java.sql.DriverManager.getConnection(Unknown Source)
    org.apache.jsp.access_jsp._jspService(access_jsp.java:78)
    org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
    org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
    org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
    org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
    javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.18 logs.
我在部署access.jsp项目时出现上面的问题,数据库数据表建立没问题,数据源jdbc-ODBC都是按标准步骤进行的
搜索更多相关主题的帖子: access jsp 数据库 
2009-12-02 22:06
柠檬可乐
Rank: 4
等 级:业余侠客
威 望:6
帖 子:66
专家分:205
注 册:2009-6-16
收藏
得分:0 
你连接数据库时的名称跟你设置的名称不相同
2009-12-17 13:06
raoyongchao
Rank: 2
等 级:论坛游民
帖 子:19
专家分:42
注 册:2009-4-13
收藏
得分:0 
数据源的配置说明.rar (116.47 KB)
看看这个数据源配置和链接文件吧
import java.sql.*;

public class DataConnector {
    String url="jdbc:odbc:CSR_DATA";
      Connection con=null;
      Statement stat=null;
      ResultSet rs=null;
      public Connection getCon(){
          try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            System.out.print("数据库驱动加载成功...");
        } catch (ClassNotFoundException e1) {
            System.out.print("数据库驱动加载失败...");
        }
          try{
                con=DriverManager.getConnection(url,"","");
                System.out.print("数据库连接成功...");
                return con;
            }
            catch(Exception e){
                System.out.print("数据库没有连接成功!");
            }
            return null;
      }
      public boolean close(){
          try{
              if(rs!=null){
                  rs.close();
              }
              if(stat!=null){
                  stat.close();
              }
              if(con!=null){
                  con.close();
              }
              return true;
          }catch(Exception e){
              System.out.print("数据库关闭失败!");
          }
          return false;
      }
      public static void main(String[] args) {
          DataConnector dataConnector=new DataConnector();
          dataConnector.getCon();
          dataConnector.close();
         
    }
      
}
2009-12-30 23:03
raoyongchao
Rank: 2
等 级:论坛游民
帖 子:19
专家分:42
注 册:2009-4-13
收藏
得分:0 
数据源的配置说明.rar (116.47 KB)
看看这个数据源配置和链接文件吧
import java.sql.*;

public class DataConnector {
    String url="jdbc:odbc:CSR_DATA";
      Connection con=null;
      Statement stat=null;
      ResultSet rs=null;
      public Connection getCon(){
          try {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            System.out.print("数据库驱动加载成功...");
        } catch (ClassNotFoundException e1) {
            System.out.print("数据库驱动加载失败...");
        }
          try{
                con=DriverManager.getConnection(url,"","");
                System.out.print("数据库连接成功...");
                return con;
            }
            catch(Exception e){
                System.out.print("数据库没有连接成功!");
            }
            return null;
      }
      public boolean close(){
          try{
              if(rs!=null){
                  rs.close();
              }
              if(stat!=null){
                  stat.close();
              }
              if(con!=null){
                  con.close();
              }
              return true;
          }catch(Exception e){
              System.out.print("数据库关闭失败!");
          }
          return false;
      }
      public static void main(String[] args) {
          DataConnector dataConnector=new DataConnector();
          dataConnector.getCon();
          dataConnector.close();
         
    }
      
}
2009-12-30 23:04
快速回复:求教jsp与access数据库连接问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018183 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved