The local variable abc is never read...!!!!!!!!!

Hi ..pardon me for this stupid and amateur question...

but like when we want certain variables to be declared and somehow we dont use them...what is the standard way of suppressing this warning...is there one prescribed in specifications..?

[253 byte] By [@developer@a] at [2007-11-27 11:10:57]
# 1

Comment out the declaration.

masijade.a at 2007-7-29 13:45:00 > top of Java-index,Java Essentials,New To Java...
# 2

> Comment out the declaration.

Yuk! Yuk! Bad!

Delete it. If it isn't needed, get rid of it. If you're keeping it there because you might need it later, delete it anyway and recover it from your version control system when the time comes. You do use a version control system don't you?!

georgemca at 2007-7-29 13:45:00 > top of Java-index,Java Essentials,New To Java...
# 3

well thats what i cant do....i mean i have to declare the variable ....it could be one of those reqts like you have to get all the values returned by a resultset in the proper order.....though you may not use one of them.....so you have to do something like

int temp=rs.getInt("val");

and you would not be using this temp anywhere but you have to get it from the resultSet

@developer@a at 2007-7-29 13:45:00 > top of Java-index,Java Essentials,New To Java...
# 4

> well thats what i cant do....i mean i have to declare

> the variable ....it could be one of those reqts like

> you have to get all the values returned by a

> resultset in the proper order.....though you may not

> use one of them.....so you have to do something like

>

>

> int temp=rs.getInt("val");

>

> and you would not be using this temp anywhere but you

> have to get it from the resultSet

do

rs.getInt("val");

instead of

int temp = rs.getInt("val");

Edit: Although nothing requires you to read the column. If you don't need it don't read it, or better yet leave it out of the query altogether.

masijade.a at 2007-7-29 13:45:00 > top of Java-index,Java Essentials,New To Java...
# 5

> > Comment out the declaration.

>

> Yuk! Yuk! Bad!

>

> Delete it. If it isn't needed, get rid of it. If

> you're keeping it there because you might need

> it later, delete it anyway and recover it from your

> version control system when the time comes. You

> do use a version control system don't you?!

It's called sarcasm! ;-)

masijade.a at 2007-7-29 13:45:00 > top of Java-index,Java Essentials,New To Java...
# 6

> int temp=rs.getInt("val");

>

> and you would not be using this temp anywhere but you

> have to get it from the resultSet

just delete it, why get data from resultset which you don't need.

Yannixa at 2007-7-29 13:45:00 > top of Java-index,Java Essentials,New To Java...
# 7

> well thats what i cant do....i mean i have to declare

> the variable ....it could be one of those reqts like

> you have to get all the values returned by a

> resultset in the proper order.....though you may not

> use one of them.....so you have to do something like

>

>

> int temp=rs.getInt("val");

>

> and you would not be using this temp anywhere but you

> have to get it from the resultSet

Like george said, if the variable is never read, it's useless! What you're saying makes no sense.

manuel.leiriaa at 2007-7-29 13:45:00 > top of Java-index,Java Essentials,New To Java...
# 8

> > > Comment out the declaration.

> >

> > Yuk! Yuk! Bad!

> >

> > Delete it. If it isn't needed, get rid of it. If

> > you're keeping it there because you might

> need

> > it later, delete it anyway and recover it from

> your

> > version control system when the time comes. You

> > do use a version control system don't you?!

>

> It's called sarcasm! ;-)

Oh really? How incredibly interesting

:-)

georgemca at 2007-7-29 13:45:00 > top of Java-index,Java Essentials,New To Java...
# 9

> well thats what i cant do....i mean i have to declare

> the variable ....it could be one of those reqts like

> you have to get all the values returned by a

> resultset in the proper order.....though you may not

> use one of them.....so you have to do something like

>

>

> int temp=rs.getInt("val");

>

> and you would not be using this temp anywhere but you

> have to get it from the resultSet

Guess your compiler must be lying to you about it never being read, then

georgemca at 2007-7-29 13:45:00 > top of Java-index,Java Essentials,New To Java...
# 10

well okie correct me if i am wrong....dont you have to read all the values returned by a resultset....more so in the order they are returned by the resultset ..?

@developer@a at 2007-7-29 13:45:00 > top of Java-index,Java Essentials,New To Java...
# 11

> well okie correct me if i am wrong....dont you have

> to read all the values returned by a

> resultset....more so in the order they are returned

> by the resultset ..?

Ok. You're wrong. Even if you did have to, you could read them without bothering to assign them to anything

georgemca at 2007-7-29 13:45:00 > top of Java-index,Java Essentials,New To Java...
# 12

> > well okie correct me if i am wrong....dont you

> have

> > to read all the values returned by a

> > resultset....more so in the order they are

> returned

> > by the resultset ..?

>

> Ok. You're wrong. Even if you did have to, you could

> read them without bothering to assign them to anything

See reply four, which had already covered both points, and added a third (remove it from the query).

masijade.a at 2007-7-29 13:45:00 > top of Java-index,Java Essentials,New To Java...
# 13

> > > well okie correct me if i am wrong....dont you

> > have

> > > to read all the values returned by a

> > > resultset....more so in the order they are

> > returned

> > > by the resultset ..?

> >

> > Ok. You're wrong. Even if you did have to, you

> could

> > read them without bothering to assign them to

> anything

>

> See reply four, which had already covered both

> points, and added a third (remove it from the query).

Oh yeh!

georgemca at 2007-7-29 13:45:00 > top of Java-index,Java Essentials,New To Java...
# 14

> well okie correct me if i am wrong....dont you have

> to read all the values returned by a

> resultset....more so in the order they are returned

> by the resultset ..?

I think what you are getting at the bold caption is the phrase in the API doc that says that you should read each column only once and in the order that they are returned, as the Driver is not required to provide anything more flexibility than that.

That does not mean that you need to read every column, though.

masijade.a at 2007-7-29 13:45:00 > top of Java-index,Java Essentials,New To Java...
# 15

hmm okie that was exactly what the confusion was..!!!

that means we can skip the columns but yet have to maintain the order

thanks :)

@developer@a at 2007-7-29 13:45:05 > top of Java-index,Java Essentials,New To Java...
# 16

> hmm okie that was exactly what the confusion

> was..!!!

> that means we can skip the columns but yet have to

> maintain the order

>

> thanks :)

Not necessarily have to, but definately should. Most Drivers give you full flexibilty to read multiple times and in any order you want to, but they are not required to.

masijade.a at 2007-7-29 13:45:05 > top of Java-index,Java Essentials,New To Java...