views:

33

answers:

1

I've been looking this over for a while now and can't seem to pinpoint the problem.

Does anything stand out that would cause a java.sql.SQLException: No data found

 ResultSet rs = null;
 rs = s.executeQuery("SELECT * FROM customer");

 out.println("<tr><th>Customer ID</th><th>First Name</th>&nbsp;</th></tr>");

 while(rs.next()) {
  out.println("<tr><td>" + rs.getString("customer_id") + "</td><td>" + rs.getString("first_name") + "</td></tr>");
 }
+1  A: 

This exception message is typical to the JDBC-ODBC bridge driver. Since you're apparently using an Oracle database, you should be using the Oracle JDBC driver, not the JDBC-ODBC bridge driver. A fullworthy JDBC driver provided by the DB vendor will perform and behave much better in all areas you can think of. The JDBC-ODBC bridge driver is full of bugs, you don't want to know.

I think I narrowed it down. customer_id is stored as a number. If I take out rs.getString("customer_id") out of the print, then it does work. should it be getInt("customer_id") or something similar?

Either replace SELECT * by SELECT colname1, colname2, colname3 or use getString(1) where 1 is the column index. But still, I'd prefer using Oracle's own pure JDBC driver.

BalusC
Interesting. I will check it out. Is there a reason the ODBC-JDBC bridge driver would work on some pages and not others (like this one)??
relyt