Hi,
I have a very weird error on my Java code. I have jdbc connection and my database have the data i request. Some how i always have a no data found exception. Here is my code: it quite simple:
It really weird cos i no that tere is a colum in the employee table call "name" and the colum is not empty. All other colum from other table in the same database return the same error. But if i query the database using the MySQL query Browser and the same query as above, i get the matcing row. Can somebody help, i spend the whole day with this problem and couldnt find a solution. Thanks
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
con = DriverManager.getConnection("jdbc:odbc:myOntoDS","","");
Statement stmt = con.createStatement();
ResultSet rs= stmt.executeQuery("SELECT * FROM employee" );
if(rs != null) {
while (rs.next())
{
System.out.println("in resultset ...");
// Here is the problem
System.out.println(rs.getString("name") +" == " +rs.getString("name"));
}}
else {
System.out.println("resultset is null");
}
}
catch(Exception ex){ex.printStackTrace();}
Here is the exception
java.sql.SQLException: No data found
at sun.jdbc.odbc.JdbcOdbc.standardError(Unknown Source)
at sun.jdbc.odbc.JdbcOdbc.SQLGetDataString(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getDataString(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
at sun.jdbc.odbc.JdbcOdbcResultSet.getString(Unknown Source)
at MysqlTest.connect(MysqlTest.java:30)
at MysqlTest.main(MysqlTest.java:81)