Hi there, new memeber here.
First of all i want to create a JSP which will fetch only the database records & will display it.
But i'm failing to do that.
Let me tell you what i have done till now.
First, i have create the database in the MS Access 2007 with two columns roll & sname with datatype number & text respectively. i saved it as 1.mdb
Then i've added the data source through Data Sources (ODBC) in Control Panel of that 1.mdb database by selecting the Microsoft Access Driver(*.mdb) &
named it as swaps.
Then i've installed JDK 1.6.10 & Tomcat 6.0.16.
Gone to localost with custom port number. It worked successfully after typing http://localhost:947/
Then i've created the directory in the C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps & named that directory as jsp.
After that i've created the following file & named it as display.jsp
<%@page language="java" import="java.sql.*"%>
<%
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn = DriverManager.getConnection("jdbc:odbc:swaps");
Statement st = cn.createStatement();
ResultSet rs = st.executeQuery("SELECT * FROM STUD");
rs.next();
out.println("The First name is " + rs.getString("sname"));
%>
But now its giving me error.
HTTP Status 500 -
--------------------------------------------------------------------------------
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /display.jsp at line 4
1: <%@page language="java" import="java.sql.*"%>
2: <%
3: Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
4: Connection cn = DriverManager.getConnection("jdbc:odbc:swaps");
5: Statement st = cn.createStatement();
6: ResultSet rs = st.executeQuery("SELECT * FROM STUD");
7: rs.next();
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:398)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
root cause
javax.servlet.ServletException: java.sql.SQLException: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:850)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:779)
org.apache.jsp.display_jsp._jspService(display_jsp.java:69)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
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.display_jsp._jspService(display_jsp.java:58)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:337)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.16 logs.
--------------------------------------------------------------------------------
Apache Tomcat/6.0.16