Arif,
the code for JSP is exactly the same as for any Java JDBC client - this is
from a servlet I have it could easily be dropped into a JSP pretty much as
is
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:Diary";
conn = DriverManager.getConnection(url);
// get a statement
stmt = m_conn.createStatement();
if(stmt != null)
{
strSelect = "SELECT * FROM DiaryEntries where userid=1";
rs = stmt.executeQuery(strSelect);
}
// and then the rowset
if(rs != null)
{
while(rs.next())
{
try
{
java.sql.Date d = rs.getDate("StartDate");
// etc...
}
}
}
stmt.close();
m_conn.close();
}
catch(Exception e)
{
}
You could wrap this up as a scriptlet, or probably a better way is to put
this into a bean and retrieve the data as you need it,
Kevin
PS
Apologies if this doesn't compile - I've copied it into this message and
hacked it about to reduce the size of the example
-----Original Message-----
From: A mailing list about Java Server Pages specification and reference
[mailto:[EMAIL PROTECTED]]On Behalf Of Arif Bilge Yorgan
Sent: 29 June 1999 15:38
To: [EMAIL PROTECTED]
Subject: sample database access
hi,
Can anyone give me some code examples about database connection
and manipulation (JSP with JDBC )?
best regards
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST". For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".