Skip to Main Content

Java Database Connectivity (JDBC)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

java.sql.SQLException: No data found (please its urge...)

843859Dec 14 2005 — edited Dec 14 2005
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)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 11 2006
Added on Dec 14 2005
1 comment
2,644 views