You have declared Statement object as a local one within init method.
put it has general property in that class.

e.g

Statement stmt;

init function()
{
    --
    --
    --
    stmt = con.createStatement();
     --
    ---
}


This should work.

Regards,
G Ramesh

-----Original Message-----
From: Parvez Lanewala <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Friday, April 28, 2000 1:16 AM
Subject: new to JDBC !!!


>hi,
>
>i'm not getting why i'm getting this error.
>can someone help me.
>
>when i compile the following code :
>
>// this is in init() function
>.....
>.....
>Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
>Connection con=DriverManager.getConnection("jdbc:odbc:data1");
>Statement stmt=con.createStatement();
>......
>......
>protected void doPost(HttpServletRequest req,
>HttpServletResponse res)
>throws ServletException, IOException
>{
>ResultSet result;
>if(req.getParameter("action").equals("publisher"))
>{
>result=stmt.executeQuery("Select * from BookDetails");
>msg=result.getString(4);
>}
>...
>...
>...
>
>This gives error as:
>------------------------------------------------------------------
>data1.java:59: Undefined variable or class name: stmt
>result=stmt.executeQuery("Select * from BookDetails");
>^
>------------------------------------------------------------------
>Where do i define result ?
>
>Thanks.
>Parvez.
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to