Hi,
I m trying to display data from Ms-access to
JSP pages in HTML. I have a table name
test in Access database with two field ID and names. But i m getting Exception as General Error my code is as under. I have trace the exception, it is at reading the data from database as it is showing the exception of ClassNotFoundException3 General Error
<%@ page
import = "java.io.*"
import = "java.lang.*"
import = "java.sql.*"
%>
<HTML>
<BODY>
<%!
String db=null;%>
<%
Connection conn = null;
String Event = new String("");
Statement stmt = null;
Statement stmt2 = null;
ResultSet rs = null;
ResultSet rs2 = null;
try
{
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
}
catch( ClassNotFoundException e )
{
%>
ClassNotFoundException1: <%= e.getMessage() %>
<%
}
try
{
db= "jdbc:odbc:Driver={MicroSoft} Access Driver (*.mdb);DBQ=C:/demo.mdb";
}
catch(Exception e )
{
%>
ClassNotFoundException2: <%= e.getMessage() %>
<%
}
try
{
conn = DriverManager.getConnection( db );
stmt = conn.createStatement();
rs = stmt.executeQuery( "SELECT * FROM test" );
%>
Names
<%
while( rs.next() )
{
%>
this is a line from the DB: <%= rs.getInt("ID") %>
<%=rs.getString("names")%>
<%
}
}
catch(Exception e )
{
%>
ClassNotFoundException3: <%= e.getMessage()%>
<%
}
finally
{
//Clean up resources, close the connection.
if( conn != null )
{
try
{
conn.close();
}
catch( Exception ignored )
{
}
}
}
%>
</BODY>
</HTML>
Please help me to solve the problem