JDBC的小问题!!!
import java.sql.*; //先建一个table1数据源连接你的数据库
class database {
public static void main(String args[]) {
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url="jdbc:odbc:table1";
Connection connection=DriverManager.getConnection(url);
Statement statement = connection.createStatement();
String sql="SELECT * FROM student";
ResultSet rs = statement.executeQuery(sql);
String tt;
while (rs.next()) {
System.out.print("姓名:" + rs.getString("Name"));
System.out.println(" 年龄:" + rs.getString("Age"));
}
rs.close();
connection.close();
}
catch(Exception ex){
System.out.println(ex);
System.exit(0);
}
}
}
建立了数据源,数据库,表。我个人感觉没有问题。但是,结果有这样错误的:
java.sql.SQLException:No data found
我不知道是怎么了,请指点,看看可能的错误,和改正方法!!!