在sql表中有一字(job_id)段数据类型为smallint.因为要与数据库连接,在jsp中 要输出该字段job_id,但这样写会出错out.print(rs.getInt("job_id")) ;,谁知道smallint怎么转换成int, 能不出错!

解决方案 »

  1.   

    getShort(String columnName) 
      

  2.   

     The   recommended   Java   mapping   for   the   JDBC   TINYINT   type   is   as   either   a   Java   byte   or   a   Java   short.  意思是说 推荐byte或者 short 你先取出来 然后强制造型即可。
      

  3.   

    晕 上面写错的
     The   recommended   Java   mapping   for   the   JDBC   SMALLINT   type   is   as   a   Java   short. 
    这句是smallint的 推荐 类型 ,显然是short
      

  4.   

    但这样写会出错out.print(rs.getInt("job_id")) ;,
    不可能哦! 把你的错误贴出来! 呵呵!!