ResultSet 获取表中指定列的值问题 困惑啊 请指点
package myproject;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import
java.sql.SQLException;
public class Main {
public static void main(String[] args) {
java.sql.Statement stm=null;
String SQLStatement = " ";
ResultSet rs=null;
String customer= " ";
try {
// Load the driver class
Class.forName( "oracle.jdbc.driver.OracleDriver ");
// Define the data source for the driver
String sourceURL = "jdbc:oracle:thin:@ "+ConfigRead.getDB_ip()+ ": "+ConfigRead.getDB_port()+ ": "+ConfigRead.getDB_name();
// Create a connection through the DriverManager
Connection databaseConnection = DriverManager.getConnection(sourceURL,ConfigRead.getDB_user(),ConfigRead.getDB_psw());
System.out.println( "Connection is: "+databaseConnection);
stm=databaseConnection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATABLE);
} catch(
ClassNotFoundException cnfe)
{
System.err.println(cnfe);
}
catch(
SQLException sqle)
{
System.err.println(sqle);
}
//查询客户信息表CUSTNO 获取一条客户信息记录
SQLStatement= "select custno from custno where cust_flag = '0 ' and rownum <=10 ";
try{
rs=stm.executeQuery(SQLStatement);
System.out.println( "no problem ");
customer=rs.getString( "CUSTNO ");
System.out.println(customer);
}
catch (SQLException e)
{
e.printStackTrace();
}
}
}
运行结果 :
Connection is: oracle.jdbc.driver.OracleConnection@197d257
no problem
java.sql.SQLException: 用尽的Resultset
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)