Dear Amn,
I am giving sample program. Just change the emp.mdb file path and run this jsp program.
Then you can see the driver information etc.,
if you get any problem, please call me at getfastreply@hotmail.com. then i will give u solution assp.
Thank you very much.
all the best.
Yours
Rajesh
<title>Database Test</title>
<font face="verdana" size=2 color="blue">
<%@page import="java.sql.*"%>
<%
Connection con=null;
Statement st=null;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection("jdbc:odbc:Driver={MicroSoft Access Driver (*.mdb)};DBQ=C:/emp.mdb","","");
st=con.createStatement();
out.println("Connected To Database ");
out.println("<BR><BR>");
DatabaseMetaData md = con.getMetaData();
out.println("Driver Name" + md.getDriverName());
out.println("<BR><BR>");
out.println("Driver Version " + md.getDriverVersion());
out.println("<BR><BR>");
out.println("Database URL is" + md.getURL());
out.println("<BR><BR>");
out.println("Database UserName is" + md.getUserName());
out.println("<BR><BR>");
out.println("Connection Name" + md.getConnection());
out.println("<BR><BR>");
out.println("Database Name " + md.getDatabaseProductName());
out.println("<BR><BR>");
out.println("Database Version" + md.getDatabaseProductVersion());
out.println("<BR><BR>");
out.println("Database ReadOnly Type " + md.isReadOnly());
out.println("<BR><BR>");
out.println("MaxColumnNameLength" + md.getMaxColumnNameLength());
out.println("<BR><BR>");
out.println("MaxConnections " + md.getMaxConnections());
out.println("<BR><BR>");
out.println("");
}
catch(Exception e)
{
out.println(e);
}
finally
{
try {
if(st != null) {
st.close();
st = null;
}
if(con != null) {
con.close();
con = null;
}
} catch (SQLException e) {}
}
%>
JDBC Drivers are included with the database by the database vendor. Otherwise, you can try to download a driver. But yes, you have to install the driver. Once you do that, include the driver in your runtime classpath, and from there, it's straight JDBC code. You can find lots of JDBC code on the examples and tutorials pages.
Go here and scroll down to JDBC:
http://developer.java.sun.com/developer/codesamples/examplets/index.html
Hello!
I have Tomcat 4.0. and my database file is in Access (emp.mdb)
I want to connect this Data file from JSP, for that any Driver I have to
install? like JDBC driver...and i want some codes how to connect the database(oracle 8i)with jsp
What is the steps and How do I connect? Pl. reply me.
Thax,
regards
ganga