Hi Walter,
You need a JDBC driver for Oracle. It can be Oracle Thick-client,
Thin-client, JDBC-ODBC bridge etc. Check with your Oracle vendor for more
information. You also need to set up a data source name to identify which
database your application is going to use.
I have included the following code sample for JSP to access database with
data source name 'myDSN' using the JDBC-ODBC bridge. You need to import the
java.sql.* class in your JSP.
Read the comments in the JSP code to see how you can display the resultset
in HTML.
Happy coding!
Will
--
<HTML><HEAD><TITLE>My Table</Title></Head>
<%@ page language="java" import="java.sql.*" %>
<Body>
<H1>My Table</h1>
<TABLE BORDER="1" WIDTH="100%">
<TR>
<TD><B>Field 1</B></TD>
<TD><B>Field 2</B></TD>
</TR>
<%
// Load the Driver class file
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Make a connection to the ODBC datasource sample
Connection con = DriverManager.getConnection("jdbc:odbc:myDSN", "",
"");
// Create the statement
Statement stmt = con.createStatement();
// Creating the Result Set object
ResultSet rSet = stmt.executeQuery("select * from myTable");
// Iterating the Result Set
if (rSet != null) {
while (rSet.next()) {
String field1 = rSet.getString("Field1");
String field2 = rSet.getString("Field2");
%>
<tr>
<td><%= field1 %></td>
<td><%= field2 %></td>
</tr>
<%
}
}
stmt.close();
con.close();
%>
</TABLE></BODY></HTML>
-----Original Message-----
From: Walter Priesnitz Filho [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 7 February 2001 4:43
To: [EMAIL PROTECTED]
Subject: JSP + ResultSets
Hi all,
I need help with an apllication.
I need make a query in an Oracle Table and put the result in a html table.
How can I pass the resultset from Oracle to JSP?
Does anybody help-me???
Thanks
-----------------------------------------
Walter Priesnitz Filho
Mestrando em Ciencia da Computacao
[EMAIL PROTECTED] | [EMAIL PROTECTED]
http://www.inf.ufsc.br/~walterp
-----------------------------------------
===========================================================================
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
===========================================================================
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