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;
listener in java
Started by Ananta2010, Jul 06 2010 05:09 AM
4 replies to this topic
#1
Posted 06 July 2010 - 05:09 AM
|
|
|
#2
Posted 06 July 2010 - 02:07 PM
#3
Posted 06 July 2010 - 04:21 PM
You query a database, loop through the result set looking for a value.
#4
Posted 07 July 2010 - 02:18 AM
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.
{
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
Posted 07 July 2010 - 02:18 AM
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
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.


Sign In
Create Account

Back to top









