aspose file tools*
The moose likes JDBC and the fly likes cannot connect to microsoft access with jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "cannot connect to microsoft access with jsp" Watch "cannot connect to microsoft access with jsp" New topic
Author

cannot connect to microsoft access with jsp

Aswin Gopan
Greenhorn

Joined: Apr 12, 2011
Posts: 3
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

Joined: Oct 17, 2009
Posts: 186


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
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
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.


Ping & DNS - updated with new look and Ping home screen widget
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: cannot connect to microsoft access with jsp
 
Similar Threads
unable to set the value of Internal attribute using <c:set>
My JSP Syntax is correct but still getting 500 error code
Could not parse configuration hibernate.cfg.xml
jsp sql error
request.setAttribute() and request.getAttribute()