This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes JDBC and the fly likes java.sql.SQLException: no data found Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Databases » JDBC
Reply Bookmark "java.sql.SQLException: no data found" Watch "java.sql.SQLException: no data found" New topic
Author

java.sql.SQLException: no data found

Rafael Fagundes
Ranch Hand

Joined: Sep 23, 2004
Posts: 52
Hi!

Well, the source code:
.......
while (rs.next()) {

ResultSetMetaData meta = rs.getMetaData();
int count = meta.getColumnCount();
Map elemento = new HashMap();

for (int i = 0; i < count; i++) {
Object o = null;

if (rs.getObject(i + 1) == null) {

o = "";

} else {
o = rs.getObject(i + 1); // ERROR LINE
}
.......

At the error line, the java.sql.SQLException: no data found is throwed. I can�t understand the reason.....

When I try this:

......
} else {
System.out.println("\n\n cod "+rs.getString(1));
o = rs.getObject(i + 1);
......

The data is normally printed...... but the exception is throwed any way.


Extra iformation:
sun.jdbc.odbc.JdbcOdbcDriver
MySQL 5
JDK 1.5

Doe�s somebody can help?

Thank�s in advance,
Rafael.


Thanks,
Rafa
Vallidevi Appana
Greenhorn

Joined: Jun 30, 2006
Posts: 25
Hi

Try this out.....

while (rs.next()) {

ResultSetMetaData meta = rs.getMetaData();
int count = meta.getColumnCount();
Map elemento = new HashMap();

for (int i = 0; i < count; i++) {
Object o = rs.getObject(i + 1);

if (o == null) {

o = "";

}


Problem might be calling getObject twice....
stu derby
Ranch Hand

Joined: Dec 15, 2005
Posts: 333


Extra iformation:
sun.jdbc.odbc.JdbcOdbcDriver
MySQL 5
JDK 1.5


I think the other poster is correct, that the 2nd call to getObject for the same column is the problem. Some drivers allow that and some don't (the JDBC allows this difference).

In particular, I think the native MySQL driver will allow it and the JDBC-ODBC bridge that you're using won't.
Rafael Fagundes
Ranch Hand

Joined: Sep 23, 2004
Posts: 52
Thank�s Vallidevi. You was completle write.
Stu derby, you are write also. On the first version of the application, I was using the native MySQL driver. There was no problem with the posted code. When I changed de driver for sun.jdbc.odbc.JdbcOdbcDriver, this problem started to happen (not because it�s a bad driver, off course; it simply dosen�t support what I was trying to do).

Thank�s all for the attention,
Rafael.

PS: Sorry for my bad english.
rocky oswal
Greenhorn

Joined: Jul 04, 2010
Posts: 3
[hijack removed]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: java.sql.SQLException: no data found
 
Similar Threads
variable problem
How to Upload a image or video where it will be attached or keep in email?
How to read and wrire date in RMS
Adding Object to ArrayList
Url cannot be null error :(