小编dav*_*ohn的帖子

从 Java 中的结果集 (Oracle db) 获取 BigInt 值

BIGINT我想使用 JDBC 从 Oracle 数据库获取值。
getBigInt()或者getBigInteger()不起作用getInt()

这是代码片段:

public List<Employee> getAllEmployees()
{
    List<Employee> employeeList = new ArrayList<Employee>();
    try
    {
        //typical jdbc coding
        Connection conn = DBUtil.getConnection();
        Statement st = conn.createStatement();
        ResultSet rs = st.executeQuery("SELECT * FROM employee1");
        while(rs.next())
        {
            Employee employee = new Employee(rs.getString("emp_id"), rs.getString("name"), rs.getBigInt("emp_mob"));
            employeeList.add(employee);
        }
        DBUtil.closeConnection(conn);  //close connection
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
    
    return employeeList;
}
Run Code Online (Sandbox Code Playgroud)

表中的 emp_mob 列包含大整数值。

java jdbc oracle11g

3
推荐指数
1
解决办法
7147
查看次数

标签 统计

java ×1

jdbc ×1

oracle11g ×1