473,398 Members | 2,125 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

What is the use of rs.getString(1) in jsp?

Hi,

i need help in JSP.
Expand|Select|Wrap|Line Numbers
  1. String stateId = request.getParameter("State");
  2.  
  3.    String query = "select distinct CITY from STATES where STATE = '"+stateId+"'";
  4.  
  5.     stmt = con.prepareStatement(query);
  6.  
  7.     rs = stmt.executeQuery();
  8.        String City=null;
  9.     while(rs.next())
  10.     { 
  11.          City=""+rs.getString(1)'
  12. }
  13.          out.print(City);
  14. }
  15. rs.close();
  16.  
  17.  
i'm getting only the last data of city in the table.
i want to get all city in the table.
how i want to write the code to get all city.,
i'm new to JSP Please Help me........,
Please Help me...,
Jan 19 '11 #1
3 11356
Rabbit
12,516 Expert Mod 8TB
You need to append to City, right now you're replacing it.
Expand|Select|Wrap|Line Numbers
  1. City=City+","+rs.getString(1)
Jan 19 '11 #2
now i'm getting all the city. Thanks for Reply Rabbit.

another doubt please help me..,

This code is javaScript
Expand|Select|Wrap|Line Numbers
  1. //Here i'm getting all the City
  2.  var result = xmlhttp.responseText;
  3. //Split the responseText  
  4. var s = result.split(" ");
  5.  
  6.  var indx = 1;
  7.  for(indx=1; indx < s.length; indx++)
  8.     {
  9.   var boxLength = document.form1.City.length;
  10.   document.form1.City.options[boxLength] = new Option(s[indx]);
  11. }
  12. document.form1.City.selectedIndex=-1;
  13.  
in the above code i'm split the response text k.
getting the result in Id="City" OPTION.

but in the option it is adding data to the previous data.

for example if i selecting KARNATAKA STATE.In the city option what r all the city store in the table under karnataka is coming k. keep this
and try one more time

if i selecting tamilnadu state.In the city option what are all the city store in the table under tamilnadu is coming but before karanataka city are not clearing.
this tamilnadu cities are adding with previous karnataka cities in option.

Please help me..

Form Code:
Expand|Select|Wrap|Line Numbers
  1. <select name="City" id="City" >
  2.  
  3. </select>
  4.  
Jan 20 '11 #3
Rabbit i got the output for past post
corrected lines r coming down and i have last doubt please help me Rabbit
old code
Expand|Select|Wrap|Line Numbers
  1. var boxLength = document.form1.City.length;
  2.  document.form1.City.options[boxLength] = new Option(s[indx]);
  3.  
i changed here
Expand|Select|Wrap|Line Numbers
  1. //var boxLength = document.form1.City.length;
  2. document.form1.City.options[indx] = new Option(s[indx]);
  3.  
now i need another help please help me..,

Two forms have ProjectCode field
it wants to have auto increment value of database
i did not try yet.this is the last doubt i completed all the thing in the Form please help me..,
please Rabbit.

i need auto increment value of database due to my HR said that once typed number in the "Project code field" not to save in the database. Example:
for the first time i enter 1 in the project code field means that number 1 not valid for another time(not to save one more time with the same project code).,

i believe u understand. please help me..,
Jan 20 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: kaiwing18 | last post by:
Hi , I have a problem relate to java and database. Could anyone answer me ?Please see the following code. import java.sql.*; public class Result { public static void main(String args) {
9
by: Seán Meehan | last post by:
Hi, Hope somebody can help because i've looked everywhere else fo ran answer. I'm connecting to an Access table with 100+ rows of data of approx 20 columns wide. I'm using getstring to "Quickly"...
2
by: Roland Hall | last post by:
I have two(2) issues. I'm experiencing a little difficulty and having to resort to a work around. I already found one bug, although stated the bug was only in ODBC, which I'm not using. It...
14
by: Roland Hall | last post by:
I have two(2) issues. I'm experiencing a little difficulty and having to resort to a work around. I already found one bug, although stated the bug was only in ODBC, which I'm not using. It...
3
by: Roland Hall | last post by:
Three times the charm? Sorry for the repost. Trying to get my account right. I have two(2) issues. I'm experiencing a little difficulty and having to resort to a work around. I already...
2
by: Paul K | last post by:
I've run into a problem using this method that I have been able to work around, but I think that there is a more elegant way. I create an array of 256 bytes and use the SHBrowseForFolders API...
3
by: GTi | last post by:
I have a SQL database and some fields may be null. This will trow an exeption: string s=new string; s=String.Format("{0}",myReader.GetString(1)); s=String.Format("{0}",myReader.GetString(2));...
3
by: JamesB | last post by:
Dim enc As New System.Text.ASCIIEncoding If enc.GetString(GetStr) = "GET" Then Dim GetURL() As Byte Sys.Marshal.Copy(pPkt, GetURL, OffsetRes + 4, 32) WebPage = enc.GetString(GetURL)...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Languageâ€, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
3
by: themoonisdown09 | last post by:
I am using Microsoft Visual Studio 2003 and Microsoft Access. Everytime I run this, it keeps throwing the exception "specified cast is not valid". I don't know what's wrong. Here is the code. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.