Iam new to jsp
this may help you
create a database file in Access and in windows control panel open ODBC data
sources setup , select user dns tab , click on add
select Access Driver click on finish , give the data source and "select" the
data base file ...click ok
in this example data source name is Movie Catalog
table name in database is Titles
Example code
<HTML>
<HEAD>
<TITLE>JSP JDBC Example 1</TITLE>
</HEAD>
<BODY>
<!-- Set the scripting language to java and -->
<!-- import the java.sql package -->
<%@ page language="java" import="java.sql.*" %>
<%
Connection con = null;
try {
// Load the Driver class file
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Make a connection to the ODBC datasource Movie Catalog
con = DriverManager.getConnection("jdbc:odbc:Movie Catalog",
"", "");
// Create the statement
Statement statement = con.createStatement();
// Use the created statement to SELECT the DATA
// FROM the Titles Table.
ResultSet rs = statement.executeQuery("SELECT * " +
"FROM Titles");
// Iterate over the ResultSet
%>
<!-- Add an HTML table to format the results -->
<TABLE BORDER="1">
<TR>
<TH>Title</TH><TH>Rating</TH><TH>Price</TH><TH>Quantity</TH>
<%
while ( rs.next() ) {
// get the title_name, which is a String
out.println("<TR>\n<TD>" + rs.getString("title_name") + "</TD>");
// get the rating
out.println("<TD>" + rs.getString("rating") + "</TD>");
// get the price
out.println("<TD>" + rs.getString("price") + "</TD>");
// get the quantity
out.println("<TD>" + rs.getString("quantity") + "</TD>\n</TR>");
}
// Close the ResultSet
rs.close();
}
catch (IOException ioe) {
out.println(ioe.getMessage());
}
catch (SQLException sqle) {
out.println(sqle.getMessage());
}
catch (ClassNotFoundException cnfe) {
out.println(cnfe.getMessage());
}
catch (Exception e) {
out.println(e.getMessage());
}
finally {(Exception
try {
if ( con != null ) {
// Close the connection no matter what
con.close();
}
}
catch (SQLException sqle) {
out.println(sqle.getMessage());
}
}
%>
</BODY>
</HTML>
"S. Jyotinarayan" <[EMAIL PROTECTED]> on 02/04/2001 04:40:06 PM
Please respond to A mailing list about Java Server Pages specification and
reference <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]
cc: (bcc: Sivakumar Chiluvuri/JAMNAGAR/RIL)
Subject: JDBC connections
How do I make a JDBC connection using JSP and MS Access database. What is
the difference between JDBC and JDBC-ODBC connections.
Thanx in advance.
Jyotinarayan.
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets