Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java.sql.SQLException: no data found

 
Rafael Fagundes
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vallidevi Appana
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 333
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[hijack removed]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic