Change this "try" to a try-with-resource
Issue-ID: DMAAP-1075
Change-Id: I2d5816bdf63301cc28d80250e2507f3a1cb96a0c
Signed-off-by: Driptaroop Das <driptaroop.das@in.ibm.com>
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
public class LoadSchema {
private static final EELFLogger logger = EELFManager.getInstance().getLogger(LoadSchema.class);
public class LoadSchema {
private static final EELFLogger logger = EELFManager.getInstance().getLogger(LoadSchema.class);
}
static void upgrade() throws SQLException {
ConnectionFactory cf = ConnectionFactory.getDefaultInstance();
}
static void upgrade() throws SQLException {
ConnectionFactory cf = ConnectionFactory.getDefaultInstance();
- Connection c = null;
- Statement stmt = null;
- try {
- c = cf.get(true);
- stmt = c.createStatement();
+ try(
+ Connection c = cf.get(true);
+ Statement stmt = c.createStatement();
+ ) {
+
// this sets the PG search_path to a consistent schema, otherwise sometimes
// we get public, and sometimes we get dmaap_admin
// this sets the PG search_path to a consistent schema, otherwise sometimes
// we get public, and sometimes we get dmaap_admin
}
} catch (IOException ioe) {
throw new SQLException(ioe);
}
} catch (IOException ioe) {
throw new SQLException(ioe);
- } finally {
- if (stmt != null) {
- try {
- stmt.close();
- } catch (Exception e) {
- logger.error("Error", e);
- }
- }
- if (c != null) {
- try {
- c.close();
- } catch (Exception e) {
- logger.error("Error", e);
- }
- }
}
}
public static void main(String[] args) throws Exception {
}
}
public static void main(String[] args) throws Exception {