diff --git metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java index ddc38b2..e959f1f 100644 --- metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java +++ metastore/src/java/org/apache/hadoop/hive/metastore/MetaStoreDirectSql.java @@ -22,6 +22,7 @@ import static org.apache.commons.lang.StringUtils.repeat; import java.sql.Connection; +import java.sql.Statement; import java.sql.SQLException; import java.text.ParseException; import java.util.ArrayList; @@ -263,12 +264,17 @@ private void doDbSpecificInitializationsBeforeQuery() throws MetaException { private void executeNoResult(final String queryText) throws SQLException { JDOConnection jdoConn = pm.getDataStoreConnection(); + Statement statement = null; boolean doTrace = LOG.isDebugEnabled(); try { long start = doTrace ? System.nanoTime() : 0; - ((Connection)jdoConn.getNativeConnection()).createStatement().execute(queryText); + statement = ((Connection)jdoConn.getNativeConnection()).createStatement(); + statement.execute(queryText); timingTrace(doTrace, queryText, start, doTrace ? System.nanoTime() : 0); } finally { + if(statement != null){ + statement.close(); + } jdoConn.close(); // We must release the connection before we call other pm methods. } }