Re: Thread or not threads?

Поиск
Список
Период
Сортировка
От per@nospam.mimer.se (Per Schröder)
Тема Re: Thread or not threads?
Дата
Msg-id Xns9095B4A108CF8pescatmimer@192.71.97.199
обсуждение исходный текст
Список pgsql-general
>
>Raymond Chui <raymond.chui@noaa.gov> wrote:

>> 2) Use batched update. Requires a JDBC 2 compliant driver.
>> The purpose is to reduce the number of server roundtrips.

>What is batched update?

PreparedStatement.addBatch() and PreparedStatement.executeBatch().

Something like this:


PreparedStatement ps = con.prepareStatement("INSERT INTO XX VALUES
(?,?,?)");


//later...
for (int i=0; i<100 /*maybe?*/; i++) {
   // Get data
   ps.setInt(1,ival);
   ps.setString(2,sval);
   ps.setFloat(3,fval);
   ps.addBatch();     // Add one record to the batch
}

// Note! nothing sent to server yet.
int sv[] = ps.executeBatch();
// Now, 100 lines are inserted in one go!
con.commit();
// Commit 100 lines



/Per Schr�der
http://developer.mimer.com

В списке pgsql-general по дате отправления:

Предыдущее
От: "Clay & Judi Kinney"
Дата:
Сообщение: Newbie Question
Следующее
От: Stuart
Дата:
Сообщение: datetime arithmatic