Results 1 to 3 of 3

Thread: JDBC batch update using spring Problem

  1. #1

    Default JDBC batch update using spring Problem

    Dear gurus,

    I have a client application that has to write lots of records (around 1 million) to a MySQL DB. To achieve this I am using the spring framework and the batch update mechanism in the following way:

    public void saveSecurities(final ArrayList<ISecurityData> securities) {
    getSimpleJdbcTemplate().getJdbcOperations().batchU pdate(
    "INSERT INTO wtrader.security_data VALUES(?,..,?)",
    new BatchPreparedStatementSetter() {
    public int getBatchSize() {
    return securities.size();
    }

    public void setValues(PreparedStatement ps, int index) throws SQLException {
    ISecurityData securityData = securities.get(index);

    ps.setString(1, securityData.getISIN());
    ...
    ps.setObject(26, securityData.getBonusLevel());
    }
    });
    }

    This method is part of a class that extends SimpleJdbcDaoSupport.

    The problem is that I see no performance improvement at all - the whole data import takes around the same time as the import without batching.
    I am using the mysql connector/j version 5.0.8. According to the documentation, this is supposed to support batching.

    Could anybody help? Thanks in advance!

    Best regards,
    Levente

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,630

    Default

    Which version of MySQL are you using? Also what kind of tables (MyISAM/InnoDB?) are you using?

    Next to that I'm not sure if MySQL supports batching at all.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3

    Default

    Hi,

    I'm using mySql 5.0 and the table is InnoDB.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •