...not sure if your question was answered, so here goes:
You don't need a servlet; a bean will do fine. The database connection can
be created in the constructor of the bean (or in any
method you create).
In your bean, you'll want to import java.sql.*; // Connection, Statement,
ResultSet, Exceptions...
then in the constructor (or a method), do
Class.forName("com.ms.jdbc.odbc.JdbcOdbcDriver"); //
this is to load the jdbcodbc driver
// you may have to use com.sun.jdbc.odbc.JdbcOdbcDriver, or another
driver of your choice...
Connection c_con = DriverManager.getConnection("jdbc:odbc:dbName");
// the database should be created/
// recognized by
the odbc
// data source
manager
st_stmt = c_con.createStatement();
String s_query = new String("SELECT Foo FROM Bar");
ResultSet rs = st_stmt.executeQuery(s_query);
// and voila! everything you need is in your ResultSet.
Hope this helps,
Brian
Ben Dudley
<Ben.Dudley@IICL. To: [EMAIL PROTECTED]
CO.UK> cc:
Sent by: A Subject: Bean Database connection
mailing list
about Java Server
Pages
specification and
reference
<JSP-INTEREST@JAV
A.SUN.COM>
08/25/1999 08:06
AM
Please respond to
Ben Dudley
I'm new to Java and I'm trying to connect to an Access database using the
servlet ->bean -> JSP model. I understand that when using servlets to
connect to a database you start the connection in the init(). How do I
manage the database connection from the Bean ? Should the bean be a servlet
?
Thanks
Ben Dudley
===========================================================================
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