【发布时间】:2021-03-26 15:53:29
【问题描述】:
我想从 jdbc 中的 oracle 数据库中获取 BigInt 值。 getBigInt() 或 getBigInteger() 不像 getInt() 那样工作。这是代码sn-p:
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;
}
表中的emp_mob 列包含大整数值。
【问题讨论】:
-
当前异常是什么?不是你的问题,但你应该在
finally块中关闭Connection、Statement和ResultSet(或使用try-with-resources)。 -
或许可以试试
getLong或getBigDecimal