no data found ms -access sql exception
class Testdb
{
public static void main(String ...arg)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c =DriverManager.getConnection("jdbc:odbc:jatindsn", "system","pwd");
System.out.println("Connection ok.");
//String t1 = "raam";
//int t2 = 10;
Statement s = c.createStatement();
ResultSet result1 = s.executeQuery("select * from Tsable1");
while(result1.next())
{
System.out.println("name" + result1.getString(1));
System.out.println("id" + result1.getString(2));
System.out.println("roll num"+result1.getString(3));
}
}
catch(SQLException e)
{
System.out.println(e);
}
catch(Exception i)
{
System.out.println(i);
}
}
}
Re: no data found ms -access sql exception
its compiled successfully but when i run it it shows :
java.sql.SQLException:no data found
but i hav written code in try n catch block !!
help plz
Re: no data found ms -access sql exception
We need to know more, where is this error occurring specifically? To get the full detail of the error, put e.printStackTrace() instead of System.out.println(e) in your catch statements.
The try and catch blocks will not prevent an error from occurring, but rather prevent your entire program from crashing in the event of an error.
Re: no data found ms -access sql exception
Ditto what ausiemcgr said. In addition, rather than using System.out to print the exception, call printStackTrace on the exception - much more informative.