22
33import static com .databricks .jdbc .common .DatabricksJdbcConstants .*;
44import static com .databricks .jdbc .common .EnvironmentVariables .*;
5- import static java .lang .Runtime .getRuntime ;
65import static java .lang .String .format ;
76
87import com .databricks .jdbc .api .IDatabricksResultSet ;
2019import com .databricks .jdbc .log .JdbcLogger ;
2120import com .databricks .jdbc .log .JdbcLoggerFactory ;
2221import com .google .common .annotations .VisibleForTesting ;
22+ import com .google .common .util .concurrent .MoreExecutors ;
2323import java .sql .*;
2424import java .util .Collections ;
2525import java .util .HashMap ;
@@ -31,9 +31,8 @@ public class DatabricksStatement implements IDatabricksStatement, IDatabricksSta
3131
3232 private static final JdbcLogger LOGGER = JdbcLoggerFactory .getLogger (DatabricksStatement .class );
3333
34- /** ExecutorService for handling asynchronous execution of statements. */
35- private final ExecutorService executor =
36- Executors .newFixedThreadPool (getRuntime ().availableProcessors () * 2 );
34+ /** Same-Thread-ExecutorService for handling execution of statements. */
35+ private final ExecutorService executor = MoreExecutors .newDirectExecutorService ();
3736
3837 private int timeoutInSeconds ;
3938 private final DatabricksConnection connection ;
@@ -646,9 +645,7 @@ void checkIfClosed() throws DatabricksSQLException {
646645 *
647646 * <p>Initiates an orderly shutdown of the executor, waiting up to 60 seconds for currently
648647 * executing tasks to terminate. If the executor does not terminate within the timeout, it is
649- * forcefully shut down. This method is called when the statement is closed to ensure that all
650- * threads are properly terminated, preventing the JVM from hanging due to lingering non-daemon
651- * threads.
648+ * forcefully shut down.
652649 */
653650 private void shutDownExecutor () {
654651 executor .shutdown ();
0 commit comments