Fork me on GitHub

Probably a newbie question — as far as I can tell, inserting multiple maps with java.jdbc results in a separate PreparedStatement created per row; is there a way to avoid this?


Use vector of column names and vector of vector of row values.


Hmm, actually that may be for the old API. Let me check the docs.

([db table rows] [db table cols-or-rows values-or-opts] [db table cols values opts])
  Given a database connection, a table name and either a sequence of maps (for
  rows) or a sequence of column names, followed by a sequence of vectors (for
  the values in each row), and possibly a map of options, insert that data into
  the database.

  When inserting rows as a sequence of maps, the result is a sequence of the
  generated keys, if available (note: PostgreSQL returns the whole rows). A
  separate database operation is used for each row inserted. This may be slow
  for if a large sequence of maps is provided.

  When inserting rows as a sequence of lists of column values, the result is
  a sequence of the counts of rows affected (a sequence of 1's), if available.
  Yes, that is singularly unhelpful. Thank you getUpdateCount and executeBatch!
  A single database operation is used to insert all the rows at once. This may
  be much faster than inserting a sequence of rows (which performs an insert for
  each map in the sequence).

  The :transaction? option specifies whether to run in a transaction or not.
  The default is true (use a transaction). The :entities option specifies how
  to convert the table name and column names to SQL entities.

seancorfield21:08:15 still needs the Using SQL section updating to the new API.'s doc generator is broken (due to specs) so it's lagging behind.


cool, thanks =)


OK, I updated the repo. Will need Michael Klishin to regen the docs.