Jump to content

listener in java

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1
Ananta2010

Ananta2010

    Newbie

  • Members
  • Pip
  • 9 posts
pls. explain me the meaning og each line of code below:

try
{
rs=st.executeQuery("Select * from form");
while(rs.next())
{
System.out.println("1");
if(rs.getString(1).equals(t.getText()))
{
t1.setText(rs.getString(2));
a=1;
break;

#2
Khaotic

Khaotic

    Learning Programmer

  • Members
  • PipPipPip
  • 62 posts
Looks like SQL to me
Check out my site: www.khaoticirc.net

#3
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
You query a database, loop through the result set looking for a value.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#4
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
try To catch error after the try-block
{
rs=st.executeQuery("Select * from form"); executes "Select * from form" on the database, This returns a resultset and stores it into 'rs'
while(rs.next()) Loop trough every row on the resultset
{
System.out.println("1"); print '1' to the console
if(rs.getString(1).equals(t.getText())) Compare the value in column 1 at the current row (changed with rs.next() ) with the text in 't'. Note that the column index starts with 1 and not with 0
{ If it's equal, execute the following:
t1.setText(rs.getString(2)); Set the text of object 't1' to the value of column 2 of the resultset
a=1; set a to 1 :P
break; Jump out of the while-loop I believe.

#5
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
Another post to get the google ad in this post so my previous one is better to read..

Edit: i posted this on a pc with a screen of 1280x1024. It really took up a lot of space ^^. Now that i'm home it's not THAT annoying :P

Edited by wim DC, 07 July 2010 - 10:08 AM.