Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Displaying a ResultSet Problem  RSS feed

 
Tom Bevan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Please bear with me if this is a simple problem, still getting my head round this stuff.
I have created a connection and successfully managed to query a MySQL db, using an HTML form with radio buttons.
However, the while loop gives me all of the results, (even if they are hidden - just moving down the record set), and I just want the one associated with the radio button.
On modification, I could not get the process.jsp to display anything other than the first correct answer.
So I'm stuck between all the resultsSet, or just the first part of it. Ideally, each radio button will select the correct record - but how?
Can anyone see where I am going wrong?


Here's some code - version 1 and 2.
Version 1:


... And this is Version 2:

 
Manish Sharma
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
i think there is some problem on this line
conn = DriverManager.getConnection( "jdbc:mysql://localhost/bibliography" );
MySql require user and password to connect with database. you can write the line like this
conn = DriverManager.getConnection( "jdbc:mysql://localhost/bibliography","username","password");
Also your DB password never be blank.
hope it will work.
with regards
Manish
Originally posted by Tom Bevan:
Hello,
Please bear with me if this is a simple problem, still getting my head round this stuff.
I have created a connection and successfully managed to query a MySQL db, using an HTML form with radio buttons.
However, the while loop gives me all of the results, (even if they are hidden - just moving down the record set), and I just want the one associated with the radio button.
On modification, I could not get the process.jsp to display anything other than the first correct answer.
So I'm stuck between all the resultsSet, or just the first part of it. Ideally, each radio button will select the correct record - but how?
Can anyone see where I am going wrong?


Here's some code - version 1 and 2.
Version 1:


... And this is Version 2:

 
Tom Bevan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, currently I don't need the password and name bit, it works ok on Tomcat without, it's only on my home computer at the moment.
It is the display of the result set that I'm having trouble with, but thank you anyway.
 
Rohit Ahuja
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bevy,
Could u just change this particular statement,
rs = st.executeQuery("SELECT FirstName, LastName, Author_ID FROM Author WHERE Author_ID <=4");
and replace it with
rs = st.executeQuery("SELECT FirstName, LastName, Author_ID FROM Author WHERE Author_ID ="+request.getParameter("author"));
and tell whether it helps??
i hope the author parameter is not coming null from the previous page...
[ July 09, 2003: Message edited by: Deepak Acharya ]
 
Tom Bevan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Deepak,
Brilliant, works fine now, thank you very much!!!
(Didn't know you vould do that.....cool!)
Humble thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!