Djinns,
It is a bit more complex than asp but here you go:
<%@ imports="com.akqa.jdbc.*;java.sql.*" %>
<%
String strDriver = "<your driver class>";
String strUrl = "<your db path>";
int iTimeOut = 10;
String strPassword = "password";
String strUserName = "UserName";
String strCatalog = "<your catalog (db) name>";
String strSQL;
strSQL = "Select * from Authors where Title_Id =" + request.getParameter("id");
//jdbc objects
Connection objConnection;
Statement objStatement;
ResultSet rstSQL;
try {
// load the driver class
// n.b. you must have this driver on your machine
Class.forName(strDriver).newInstance();
// set a timeout for login and query
DriverManager.setLoginTimeout(iTimeOut);
objConnection = DriverManager.getConnection(strURL, strUsername,
strPassword);
// create a statement
objStatement = objConnection.createStatement();
// select the database
objConnection.setCatalog(strCatalog);
// execute a query
rstSQL = objStatement.executeQuery(strSQL);
if ( rstSQL.next() ) {
do {
out.println( rstSQL.getString("<column name>");
} while ( rstSQL.next() );
}
} catch(Exception e) {
// re-raise any errors to the caller
out.println ( "Error: " + e.toString() );
}
%>
This may not be perfect but it will get you on the right track.
Cheers
Martin
-----Original Message-----
From: Abhinav Nath [SMTP:[EMAIL PROTECTED]]
Sent: Tuesday, November 02, 1999 8:33 AM
To: [EMAIL PROTECTED]
Subject: Parametrized Query
Thanks Phil,
Comming from ASP background where things like passing parameters
via Request object b/w pages is quiet easy.May be things are as simple in
jsp too it question of getting used to the things, and availability of good
online Resources like ASP has www.activeserverpages.com and
www.4guysfromrolla.com these sites are virtual bibles for any ASP Developer.
A very good article at http://www.ASPToday.com/articles/19991022.htm
actually compares ASP and JSP and I found it useful, atleast for those
who are from Microsoft background.
So I would like to thanks every one who took out time to answer my Question
on Parametrized Query, and I can now pass parameters and use them in SQL
Statements using QueryString but as pointed out by my friend on this list
that Sql-String is not a good design practise
could any one tell that How do I pass parameters using form fields or Hidden
fields in Jsp.
A compareable code of what I want to do in ASP can be
<%
option Explicit
Dim mId
mId= Request.Form("id")------------->Passed has a hidden field
%>
<%
Set Conn = Server.CreateObject("ADODB.Connection")
--------
--------
-------
Sql="Select * from Authors where Title_Id = id "
Set Rs= Conn.Execute(Sql)
%>
If some one can provide JSP version of this It would make my day
Thanks
Djinns
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com
===========================================================================
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