Skip to content
Snippets Groups Projects
Commit 5349851f authored by Huaxin Gao's avatar Huaxin Gao Committed by Sean Owen
Browse files

[SPARK-12088][SQL] check connection.isClosed before calling connection…

In Java Spec java.sql.Connection, it has
boolean getAutoCommit() throws SQLException
Throws:
SQLException - if a database access error occurs or this method is called on a closed connection

So if conn.getAutoCommit is called on a closed connection, a SQLException will be thrown. Even though the code catch the SQLException and program can continue, I think we should check conn.isClosed before calling conn.getAutoCommit to avoid the unnecessary SQLException.

Author: Huaxin Gao <huaxing@oc0558782468.ibm.com>

Closes #10095 from huaxingao/spark-12088.
parent ec2b6c26
No related branches found
No related tags found
No related merge requests found
......@@ -498,7 +498,7 @@ private[sql] class JDBCRDD(
}
try {
if (null != conn) {
if (!conn.getAutoCommit && !conn.isClosed) {
if (!conn.isClosed && !conn.getAutoCommit) {
try {
conn.commit()
} catch {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment