Hello What u did in ur query was wrong .
U have Printed the ResultSet Object instead of the Id value.
U No need to Use select * from in ur query instead u can give
String qry="select id from DETAILS"
ResultSet rs=statement.executeQuery(qry);
Then u can give as
output.print("<H2>Your Id that you need for future
logins is " + rs.getInt(1) + "<BR> Please keep it safely</H2>");
statement.close();
More than that u are opening and closing ur statement object each and every time.
No Need U can keep ur statement object as Instant Variable of ur Servlet.
And open/close ur ResultSet as and when the need arise.
That should be ideal and efficient way of using the database connection.
However,If u can,Try to use connection pooling to reduce the burden of
Oppening the connection and closing each and every time.
With regards
Yogaraj
*********** REPLY SEPARATOR ***********
On 2/4/01 at 8:52 PM The Burkes wrote:
>That "error", which is not an error at all, unless you are referring to you
>and not the runtime, is a result of calling your ResultSet's toString()
>method. You must be concatenating the ResultSet onto your happy message for
>the user.
>
>When you add the record to the db set a variable, an int I'm guessing, equal
>to that unique ID field in the db. Concatenate and display, and the deed is
>done.
>
>-----Original Message-----
>From: A mailing list for discussion about Sun Microsystem's Java Servlet
>API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
>Jennifer Feeney
>Sent: Sunday, February 04, 2001 2:21 PM
>To: [EMAIL PROTECTED]
>Subject: sun.jdbc.odbc.JdbcOdbcResultSet@4cd80046 ERROR!
>
>
>Hi all,
>
>I would really appreciate any help with this problem,
>so thanks to anyone that responds to this question in advance..Thank
>you!
>
>Description:
>----------------------------------------------------------
>I have build a servlet that allows people to register themselves
>so that they can enter my site to download an application(to their
>PDA) that will allow them to do their shopping via their PDA.....
>
>That part works fine....JDBC_ODBC bridge, establishing a connectin
>with the darabase etc, and generating an ID number for each person
>that registers, all works fine.
>
>Problem:
>-----------------------------------------------------------------
>When they register, my servlet responds with a thank you messgae if
>registration was successful, HOWEVER, I also want the servlet to
>return to them, their uniques ID number, that they will need for
>login, this number is contained in an "Id" field in my database, and
>I want they servlet to pass this back to the user when i pass back
>the thank you message.
>
>BUT, what actuall comes back is the following.
>
>"Your Id that you need for future logins is
>sun.jdbc.odbc.JdbcOdbcResultSet@4cd80046
>Please keep it safely
>Thank you Tom for registering."
>
>so it is returning "sun.jdbc.odbc.JdbcOdbcResultSet@4cd80046" instead
>of the actual Id number. The "@4cd80046" changes every time.
>
>I get no error during compilation or during the connection to the
>database......
>
>Could anybody please explain what I am doing wrong?
>
>Or could anyone pass on a snippet of code that they use to return
>info from a database and display it on a html page to the user, I
>have seen code that returns the infor to a Java GUI, but not to a
>html page.
>
>Below Is the code that I am using in my servlet, that causes the
>problem I have explained above.
>
>
>boolean success = insertIntoDB(
> "'" + email + "','" + firstName + "','" + lastName + "','" +
> telNo + "','" + address1 + "','" + address2 +
> "','" + county + "','" + country + "','" +
>(String.valueOf(IdNo)) + "','" + password + "'");
>
>
> if ( success ){
>
> try{
>
> Statement statement =
>connection.createStatement();
> String query = "SELECT * FROM Details ";
>
> output.print("\nSending Query: " +
>connection.nativeSQL( query ) + "\n" );
> ResultSet rs = statement.executeQuery(
>query );
> output.print("<H2>Your Id that you need for future
>logins is " + rs + "<BR> Please keep it safely</H2>");
> statement.close();
> }
>
>
> catch ( SQLException sqlex ){
> sqlex.printStackTrace();
> //output.append( sqlex.toString() );
> }
>
> output.print( "<H2>Thank you " + firstName +
> " for registering.<BR><BR> <A
>Href = Login.html> Login In </A></H2>");
>
>
> }
>
> else
> output.print( "<H2>An error occurred. " +
> "Please try again later.</H2>" );
>
>
>
>
>
> output.close();
>
>
>I would greatly appreciate any help on this one!
>Regards.
>Jennifer
>
>
>
>_____________________________________
>
>Get your free E-mail at http://www.ireland.com
>
>___________________________________________________________________________
>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
---------------------------------------------------------------------------------------------------------------------------------
"To fail to prepare is to prepare to fail"
---------------------------------------------------------------------------------------------------------------------------------
yogaraj,
Email - [EMAIL PROTECTED]
Web Site- www.3rdagenda.com
------------------------------------------------
___________________________________________________________________________
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