Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Displaying a ResultSet Problem

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic