The ResultSet.next() returns false....

Hai,

I am working on jdbc. The connection credentials all correct, and its getting connected to the sybase without any problems. But I am not able to perform any 'select' or "update" statements...There are no exception or any errors...But the ResultSet.next() returns false and executeUpdate returns 0 . .

I think you can help me.....Thanks...

[364 byte] By [2569a] at [2007-11-27 2:36:31]
# 1
If the update returns 0 it's because it didn't update any rows.For the select, if the result set is returning false from next then it's because the query didn't return any rows.It doesn't lie.Message was edited by: dcminter
dcmintera at 2007-7-12 2:55:52 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2

But the same query gives results , in the database environment(sybase)

The 'conditions' ,query structure all are the same. I have checked this with two methods in jdbc ie executeQuery() and prepareStatement(),but both these methods don't retreive any values from the tables..........

I think u can answer this porblem.....Kindly expect your consideration

2569a at 2007-7-12 2:55:52 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
Post an example of the problem code.
masijade.a at 2007-7-12 2:55:52 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 4
> But the same query gives results , in the > database environment(sybase)Then it's not the same query, or it's not the same database.
dcmintera at 2007-7-12 2:55:52 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 5
Yes the query is same ...The thing is it doesn't show any exception Is there any situation in which sybase doesn't throw any exception even though there are some errors...
2569a at 2007-7-12 2:55:52 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 6

When you catch and ignore them. That is one of the reasons we want to see your code. The other is, is that you are probably creating the query "piecemeal" i.e. "string" + var + "string" + ..... and. many times, people forget a space in at least one of those strings, and then also catch, and ignore, exceptions, and then complain about exactly the type of thing you are complaing about here.

Try printing out the query directly before executing it, and then copy and paste that query into your db tool and see what it produces, then.

masijade.a at 2007-7-12 2:55:52 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 7
> Yes the query is sameHow do you know? Given that it's returning different values I'd at least entertain the idea that I might be wrong about that.There's also the "are you connected to the database you think you're connected to" issue...
dcmintera at 2007-7-12 2:55:52 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 8

> Yes the query is same

As already pointed out, there are ONLY two possibilities.

1. The query is not the same

2. The database is not the same.

You are making assumptions about what is going on and then drawing conclusions.

You need to understand that you assumptions are wrong. So it doesn't matter what conclusion you draw.

In terms of why the query isn't the same there could be any number of reasons but usually it is because you are passing in data and that data isn't what you think (assume) it is. It can also be that you are constructing the SQL and that construction is different. It could be that the environment that you use to test as settings which impact SQL.

jschella at 2007-7-12 2:55:52 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...