求教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 数据库
----------------解决方案--------------------------------------------------------
你连接数据库时的名称跟你设置的名称不相同
----------------解决方案--------------------------------------------------------
看看这个数据源配置和链接文件吧
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();
}
}
----------------解决方案--------------------------------------------------------
看看这个数据源配置和链接文件吧
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();
}
}
----------------解决方案--------------------------------------------------------