Program: 29380
Project: 29380
Buggy source:
/** 
 * Get a sql connection from the DataSource specified by the jdbcJndiName. This API is intended to be used in the DAS. The motivation for having this API is to provide the CMP backend a means of acquiring a connection during the codegen phase. If a user is trying to deploy an app on a remote server, without this API, a resource reference has to be present both in the DAS and the server instance. This makes the deployment more complex for the user since a resource needs to be forcibly created in the DAS Too. This API will mitigate this need.
 * @param resourceInfo the jndi name of the resource being used to get Connection fromThis resource can either be a pmf resource or a jdbc resource
 * @return a java.sql.Connection
 * @throws java.sql.SQLException in case of errors
 */
public Connection getConnection(ResourceInfo resourceInfo) throws SQLException {
  java.sql.Connection con=null;
  try {
    PoolInfo poolInfo=getPoolNameFromResourceJndiName(resourceInfo);
    if (_logger.isLoggable(Level.FINE)) {
      _logger.fine("String_Node_Str" + poolInfo);
    }
    if (poolInfo == null) {
      throw new SQLException("String_Node_Str" + poolInfo + "String_Node_Str");
    }
    con=(java.sql.Connection)getUnpooledConnection(poolInfo,null,true);
    if (con == null) {
      String i18nMsg=localStrings.getString("String_Node_Str");
      throw new SQLException(i18nMsg);
    }
  }
 catch (  ResourceException re) {
    SQLException sqle=new SQLException(re.getMessage());
    sqle.initCause(re);
    _logger.log(Level.WARNING,"String_Node_Str",re.getMessage());
    if (_logger.isLoggable(Level.FINE)) {
      _logger.fine("String_Node_Str" + re);
    }
    throw sqle;
  }
catch (  Exception ex) {
    SQLException sqle=new SQLException(ex.getMessage());
    sqle.initCause(ex);
    _logger.log(Level.WARNING,"String_Node_Str",ex.getMessage());
    if (_logger.isLoggable(Level.FINE)) {
      _logger.fine("String_Node_Str" + ex);
    }
    throw sqle;
  }
  return con;
}

Fixed version (ground truth):
/** 
 * Get a sql connection from the DataSource specified by the jdbcJndiName. This API is intended to be used in the DAS. The motivation for having this API is to provide the CMP backend a means of acquiring a connection during the codegen phase. If a user is trying to deploy an app on a remote server, without this API, a resource reference has to be present both in the DAS and the server instance. This makes the deployment more complex for the user since a resource needs to be forcibly created in the DAS Too. This API will mitigate this need.
 * @param resourceInfo the jndi name of the resource being used to get Connection fromThis resource can either be a pmf resource or a jdbc resource
 * @return a java.sql.Connection
 * @throws java.sql.SQLException in case of errors
 */
public Connection getConnection(ResourceInfo resourceInfo) throws SQLException {
  java.sql.Connection con=null;
  try {
    PoolInfo poolInfo=getPoolNameFromResourceJndiName(resourceInfo);
    if (poolInfo == null) {
      throw new SQLException("String_Node_Str");
    }
    if (_logger.isLoggable(Level.FINE)) {
      _logger.fine("String_Node_Str" + poolInfo);
    }
    con=(java.sql.Connection)getUnpooledConnection(poolInfo,null,true);
    if (con == null) {
      String i18nMsg=localStrings.getString("String_Node_Str");
      throw new SQLException(i18nMsg);
    }
  }
 catch (  ResourceException re) {
    SQLException sqle=new SQLException(re.getMessage());
    sqle.initCause(re);
    _logger.log(Level.WARNING,"String_Node_Str",re.getMessage());
    if (_logger.isLoggable(Level.FINE)) {
      _logger.fine("String_Node_Str" + re);
    }
    throw sqle;
  }
catch (  Exception ex) {
    SQLException sqle=new SQLException(ex.getMessage());
    sqle.initCause(ex);
    _logger.log(Level.WARNING,"String_Node_Str",ex.getMessage());
    if (_logger.isLoggable(Level.FINE)) {
      _logger.fine("String_Node_Str" + ex);
    }
    throw sqle;
  }
  return con;
}