try
{
Connection con = Drivermanager.getConnection("jdbc:odbc:project","","");
Statement sql = con.createStatement();
ResultSet rs = sql.executeQuery("select distinct ForeName from project1");
while(rs.next())
{
System.out.println(rs.getString("ForeName"));
}
}
catch(SQLException e)
{ System.out.println(e);}
finally {
rs.close();
sql.close();
con.close();}
{
Connection con = Drivermanager.getConnection("jdbc:odbc:project","","");
Statement sql = con.createStatement();
ResultSet rs = sql.executeQuery("select distinct ForeName from project1");
while(rs.next())
{
System.out.println(rs.getString("ForeName"));
}
}
catch(SQLException e)
{ System.out.println(e);}
finally {
rs.close();
sql.close();
con.close();}
改成Statement sql = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_READONLY);
可能是你的游标模式不对.
我像这样恐怕不行,每次用完ResultSet都要关闭close(),要不然的话会把你的内存吃没的