使用异常处理:try{
}catch(SQLException e){}

解决方案 »

  1.   

    我有try{
       
    }
    catch(SQLException e)
      

  2.   

    在你的handleEvent方法里也加上try , java.sql.SQLException; must be caught or declared to be thrown
                              t1.setText(rs.getString("name"));这句错误提示就是告诉你 java.sql.SQLException这个异常必需要catch或throw上一层。
      

  3.   

    谢谢你,但是我还是不知道这个异常怎么处理,谁能把这个handleEvent方法给我写一下,我写了半天还是过不去,依然是那个提示,谢谢了
      

  4.   

    try{
    public boolean handleEvent(Event evt){}}catch(Exception e){}
      

  5.   

    public boolean handleEvent(Event evt) throws SQLException{
      

  6.   

    方式一:
    public boolean handleEvent(Event evt) throws java.sql.SQLException{
      ...
    }方式二:
    public boolean handleEvent(Event evt){
    switch (evt.id){
      case(Event.WINDOW_DESTROY):
        System.exit(0);
      case(Event.ACTION_EVENT):{
        if(evt.id==Event.WINDOW_DESTROY){
          System.exit(0);}
        else if (evt.target instanceof Button){
          try{
            ...;
          }catch(java.sql.SQLException sqle){
            // 你的异常处理
          }
        }
      }
      default:
       ...;
    }// End switch
    }// End method