private Connection getNewConnection()
    {
     try
{
this.connection.close();

     finally
{
this.connection=null;
try
{
Class.forName(this.driverName);
try
{
this.connection=DriverManager.getConnection(this.url,this.userName,
                                    this.password);
}
catch(SQLException e)
{
    throw e;
}
}
finally
{
return this.connection;
}
}
    }

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【wufongming】截止到2008-06-26 11:12:24的历史汇总数据(不包括此帖):
    发帖数:36                 发帖分:1560               
    结贴数:35                 结贴分:1460               
    未结数:1                  未结分:100                
    结贴率:97.22 %            结分率:93.59 %            
    值得尊敬
      

  2.   


     private Connection getNewConnection() 
        { 
        try 

    this.connection.close(); 

        finally 

    this.connection=null; 
    try            //这个try后面没跟catch或finally

    Class.forName(this.driverName); 
    try 

    this.connection=DriverManager.getConnection(this.url,this.userName, 
                                        this.password); 

    catch(SQLException e) 

        throw e; 


    finally 

    return this.connection; 


        }
      

  3.   


    你这样嵌套也太麻烦了吧.TRY
    {}
    CATCH(EXCEPTION E)
    {
    }
    FINALLY
    {}这样写.不要写嵌套了.一次完成
      

  4.   

    这个应该是eclipse中的一个警告
    原因是eclipse认为finally中不应该出现return
    如果try{}中有一个return在finally{}中还有一个return
    这样try{}中的return就不会执行了
    不过LZ的这段代码 不会有任何影响
    例如下面的代码public class Test { public static int getReturn() {
    try {
    return 0;
    } finally {
    return 1;
    }
    }
    }
      

  5.   

    不对啊,我整理下,eclispe是黄色的提示,应该不属于错误
    private Connection getNewConnection()
    {
      try
      {
        this.connection.close();
      } 
        finally
      {
        this.connection=null;
        try
        {
          Class.forName(this.driverName);
          try
             {
         this.connection=DriverManager.getConnection       (this.url,this.userName,this.password);
               }
       catch(SQLException e)
               {
                  throw e; 
               }
    }
            finally
    {
               return this.connection;
            }
        }
    }
      

  6.   

    改成下面的可能会好一些 private Connection getNewConnection() {
    try {
    if (this.connection != null) {
    this.connection.close();
    this.connection = null;
    }
    Class.forName(this.driverName);
    this.connection = DriverManager.getConnection(this.url,
    this.userName, this.password);
    } catch (SQLException e) {
    e.printStackTrace();
    } catch (ClassNotFoundException e) {
    e.printStackTrace();
    }
    return this.connection;
    }
      

  7.   

    yirentianran  的这段比较简洁,呵.