int范围是-65536到65535,所以8位的一定要用long了java.sql.ResultSetgetLong
public long getLong(int columnIndex)
             throws SQLExceptionRetrieves the value of the designated column in the current row of this ResultSet object as a long in the Java programming language. Parameters:
columnIndex - the first column is 1, the second is 2, ... 
Returns:
the column value; if the value is SQL NULL, the value returned is 0 
Throws: 
SQLException - if a database access error occurs

解决方案 »

  1.   

    getLong
    public long getLong(int columnIndex)
                 throws SQLExceptionRetrieves the value of the designated column in the current row of this ResultSet object as a long in the Java programming language. Parameters:
    columnIndex - the first column is 1, the second is 2, ... 
    Returns:
    the column value; if the value is SQL NULL, the value returned is 0 
    Throws: 
    SQLException - if a database access error occurs--------------------------------------------------------------------------------getFloat
    public float getFloat(int columnIndex)
                   throws SQLExceptionRetrieves the value of the designated column in the current row of this ResultSet object as a float in the Java programming language. Parameters:
    columnIndex - the first column is 1, the second is 2, ... 
    Returns:
    the column value; if the value is SQL NULL, the value returned is 0 
    Throws: 
    SQLException - if a database access error occurs
    方法是有的,是不是你数据库里的字段不是数字形的?好好看看
      

  2.   

    我数据库里设的是numeric,类里设为long,当我用rst.getLong("EID")是就出错了:
            javax.servlet.ServletException: hp.Hr.getEID()F
    这是怎么回事呢?
    请高手指点一下,多谢了!
      

  3.   

    你String str=rst.getString(“EID”);不就行了么?
      

  4.   

    晕。你的数据库里面的数字明明是有小数的
    怎么能用long呢?
    这样就应该用double了
      

  5.   

    沒有小數也可以用getDouble()去啊。
    或者getBigDecimal()再不行就將數據庫裡面的改為varchar(8)不就行啦﹐ 折衷的辦法﹗
      

  6.   

    员工号又不用计算,干嘛要用long呢?直接varchar就好了啊!
      

  7.   

    为什么不行呢?就用varchar,取的时候用rst.getString
    工号又不用于计算,就算要计算,在把它转成long也行啊。
      

  8.   

    但是我用varchar的时候是显示不全呀
      

  9.   

    用varchar显示不全?我想应该你的类里面有用于转换Unicode与ASCII码的过滤器Filter.java
    在你取这些工号的时候你把这些工号当成是汉字来处理就行了这样就可以显示全了