Skip to content

Conversation

@huaxingao
Copy link
Contributor

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.

@huaxingao
Copy link
Contributor Author

I guess I don't need to provide a regression test. Currently, in JDBCSuite, there are lots of Warning as the following, the Warning will be gone after the fix.

13:11:51.738 WARN org.apache.spark.sql.execution.datasources.jdbc.JDBCRDD: Exception closing connection
org.h2.jdbc.JdbcSQLException: The object is already closed [90007-183]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:345)
at org.h2.message.DbException.get(DbException.java:179)
at org.h2.message.DbException.get(DbException.java:155)
at org.h2.message.DbException.get(DbException.java:144)
at org.h2.jdbc.JdbcConnection.checkClosed(JdbcConnection.java:1466)
at org.h2.jdbc.JdbcConnection.checkClosed(JdbcConnection.java:1444)
at org.h2.jdbc.JdbcConnection.getAutoCommit(JdbcConnection.java:447)

@srowen
Copy link
Member

srowen commented Dec 2, 2015

LGTM

@srowen
Copy link
Member

srowen commented Dec 2, 2015

Jenkins, test this please

@srowen
Copy link
Member

srowen commented Dec 2, 2015

Jenkins, retest this please

@SparkQA
Copy link

SparkQA commented Dec 2, 2015

Test build #47057 has finished for PR 10095 at commit 0efeb95.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

asfgit pushed a commit that referenced this pull request Dec 3, 2015
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 <[email protected]>

Closes #10095 from huaxingao/spark-12088.

(cherry picked from commit 5349851)
Signed-off-by: Sean Owen <[email protected]>
@asfgit asfgit closed this in 5349851 Dec 3, 2015
@srowen
Copy link
Member

srowen commented Dec 3, 2015

Merged to master/1.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants