Skip to content

Commit

Permalink
Final trimming
Browse files Browse the repository at this point in the history
  • Loading branch information
CK50 committed Dec 22, 2015
1 parent cae0f58 commit 5a7f262
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ object JdbcUtils extends Logging {
* Returns a PreparedStatement that inserts a row into table via conn.
*/
def insertStatement(conn: Connection, table: String, rddSchema: StructType): PreparedStatement = {
val sql = rddSchema.fields.map(field => field.name)
.mkString(s"INSERT INTO $table ( ", ", ", " ) " ) +
rddSchema.fields.map(field => "?")
.mkString("VALUES ( ", ", ", " )" )
val columns = rddSchema.fields.map(_.name).mkString(",")
val placeholders = rddSchema.fields.map(_ => "?").mkString(",")
val sql = s"INSERT INTO $table ($columns) VALUES ($placeholders)"
conn.prepareStatement(sql)
}

Expand Down

0 comments on commit 5a7f262

Please sign in to comment.