Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Java MySQL PreparedStatement Batch


Prepare sua declaração e consulta fora do loop:
      s = ("insert into " + this.database + ".user (nickname) values (?)");
      this.preparedStatement = this.connect.prepareStatement(s);
      for (String key : this.map.keySet())
        {
            this.preparedStatement.setString(1, key);
            this.preparedStatement.addBatch();
        }
        this.preparedStatement.executeBatch();