• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot connect to microsoft access with jsp

 
Aswin Gopan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i've been trying to connect access db through jsp..
this is my code...
\
------------------------------
<%@page import="java.sql.DriverManager"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<HTML>
<BODY>
<%
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String db = "jdbcdbcriver={Microsoft AccessDriver(*.accdb)};DBQ=C:\\Program Files\\Apache Software Foundation\\Tomcat 5.5\\webapps\\begin\\just.accdb";
conn = DriverManager.getConnection( db );
stmt = conn.createStatement();
rs = stmt.executeQuery("SELECT * FROM account");
%><BR>Password<BR><%
while( rs.next())
{
%>this is a line from the DB: "<%= rs.getString("password")%>" <BR><%
}
%>
</BODY>
</HTML>

-----------------
i get the following error....

javax.servlet.ServletException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
org.apache.jsp.connect_jsp._jspService(connect_jsp.java:87)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

root cause

java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
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.connect_jsp._jspService(connect_jsp.java:64)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:369)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:308)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:259)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

-----------------

The problem is that i use windows 7 and i am not able to add data source in odbc - they say microsoft access driver is missing....
what do do...? please help.
 
Ankit Tripathi
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


String db = "jdbcdbc:driver={Microsoft AccessDriver(*.accdb)};DBQ=C:\\Program Files\\Apache Software Foundation\\Tomcat 5.5\\webapps\\begin\\just.accdb";



is it same to

String db=jdbcdbcriver={Microsoft Access Driver (,*.accdb)};DBQ=C:/Program Files/Apache Software Foundation/Tomcat 5.5/webapps/begin/just.accdb;"


I don't think so....
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you can't configure ODBC, then you can't use ODBC. It might still be possible if you know the path to the Access Db file; see http://www.coderanch.com/how-to/java/OdbcJdbcQuestions for details.

Be aware that Access is not a good choice for concurrent access needs, and that the JDBC/ODBC bridge is not thread-safe. In other words, using this kind of setup in a web app can easily lead to problems.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic