Try the following:
<html>
<body>
<pre>
<%
// Load the JDBC Class Drivers
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(java.lang.ClassNotFoundException e)
{
out.println("ClassNotFoundException: " + e.getMessage());
}
java.sql.Connection con;
java.sql.Statement stmt;
try
{
con =
java.sql.DriverManager.getConnection("jdbc:odbc:odbc_data_source",
"DB_username", "DB_Password");
stmt = con.createStatement();
java.sql.ResultSet rs = stmt.executeQuery("select * from
tableone");
java.sql.ResultSetMetaData rsmd = rs.getMetaData();
int numberOfColumns = rsmd.getColumnCount();
while (rs.next())
{
for (int i = 1; i <= numberOfColumns; i++)
{
out.print(rs.getString(i) + " ");
}
out.println();
}
stmt.close();
con.close();
}
catch(java.sql.SQLException ex)
{
System.err.print("SQLException: ");
System.err.println(ex.getMessage());
out.println("SQLException: ");
out.println(ex.getMessage());
}
%>
</pre>
</body>
</html>
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]] On Behalf Of Taran Lamba
Sent: Friday, August 27, 1999 9:34 AM
To: [EMAIL PROTECTED]
Subject: Accessing Database from JSp
Can somebody send me the code which gets the data from the database and
displays the same on the screen
TIA
Taran
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html