JSP and Database connectivity

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 toinstall? like JDBC driver...What is the steps and How do I connect? Pl. reply me.Thax,regardsmohan
[294 byte] By [amn11a] at [2007-9-19]
# 1

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) {}

}

%>

rajeshkumar77a at 2007-7-8 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 2

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

wbrackena at 2007-7-8 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 3
Dear Rajesh,Good Day! I followed your steps and I got success.Thank you, Thank you very much.With regards,Mohan
amn11a at 2007-7-8 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 4

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

gangadevia at 2007-7-8 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 5
Hello!I have Tomcat 4.0. and i want to connect jsp online form codes with database(oracle 8i).Awaiting your reply.regardsganga
gangadevia at 2007-7-8 > top of java,Enterprise & Remote Computing,Web Tier APIs...
# 6
Can please give me the url address where i can get to download jdbc-obdc driver
ongomma at 2007-7-8 > top of java,Enterprise & Remote Computing,Web Tier APIs...