Github user srowen commented on a diff in the pull request:
https://github.com/apache/spark/pull/9465#discussion_r44146876
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala ---
@@ -276,7 +276,7 @@ final class DataFrameWriter private[sql](df: DataFrame)
{
if (!tableExists) {
val schema = JdbcUtils.schemaString(df, url)
val sql = s"CREATE TABLE $table ($schema)"
- conn.prepareStatement(sql).executeUpdate()
+ conn.createStatement.executeUpdate(sql)
--- End diff --
Hm, it occurs to me that there are several places where `prepareStatement`
or `createStatement` are called, but the `Statement` is not explicitly
`close()`ed. They're the two here that you are changing, plus a few others.
`JDBCRDD`:
```
val rs = conn.prepareStatement(s"SELECT * FROM $table WHERE
1=0").executeQuery()
```
`JdbcUtils.tableExists`
```
Try(conn.prepareStatement(dialect.getTableExistsQuery(table)).executeQuery()).isSuccess
```
I'm OK to commit this as-is since it's a fix for DDL, but you'd be welcome
to also correct handling of the `Statement` here, and then while at it, correct
the other 2 occurrences in the code base nearby.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]