猿问

求大神看看异常怎么解决

 public item itemmessage1(int id ){
  Connection conn=null;
 
  PreparedStatement st=null;
  ResultSet rs=null;
  try {
   conn=user.getconnection();
   String sql="select * from chongqing where id=?;";
   st=(PreparedStatement) conn.prepareStatement(sql);
   st.setInt(1, id);
   rs=st.executeQuery();
   if(rs.next())
   {
    item it=new item();
    it.setId(rs.getInt("id"));
    it.setName(rs.getString("name"));
    it.setPrice(rs.getDouble("price"));
    it.setPicture(rs.getString("picture"));
    return it;
   }else
   {
    return null;
   }
  
  } catch (Exception e) {
   
   return null;
  }finally{
   if(rs!=null)
   {
    try {
     rs.close();
     rs=null;
    } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
    }
    if(st!=null)
    {
     try {
      st.close();
      st=null;
     } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
     }
   }
  }
 
  
 
}}

item it=read1.itemmessage1(Integer.parseInt(request.getParameter("id")));这句话出现了

java.lang.NumberFormatException: null

求大神解决

木木甫
浏览 1385回答 1
1回答

qq_乐派_03747475

把异常贴出来
随时随地看视频慕课网APP

相关分类

Java
MySQL
我要回答