| 1 19 20 package org.polepos.teams.jdbc.drivers.melbourne; 21 22 import org.polepos.data.*; 23 import org.polepos.teams.jdbc.*; 24 25 26 27 36 public class BulkWriteMultiValue implements BulkWriteStrategy 37 { 38 private final JdbcCar mCar; 39 40 43 public BulkWriteMultiValue( JdbcCar car ) 44 { 45 mCar = car; 46 } 47 48 51 public void savePilots( String tablename, Pilot[] p, int count, int index) 52 { 53 if ( count == 0 ) return; 54 StringBuffer stmt = new StringBuffer ( "insert into "); 55 stmt.append(tablename); 56 stmt.append(" (id,Name,FrontName,Points,LicenseID) values " ); 57 for ( int i = 0; i < count-1; i++ ) 58 { 59 values( stmt, p[i], index++ ); 60 stmt.append(","); 61 } 62 values( stmt, p[count-1], index++ ); 63 64 mCar.executeSQL( stmt.toString() ); 65 } 66 67 68 71 private void values( StringBuffer to, Pilot p, int idx ) 72 { 73 to.append( "(" ).append( Integer.toString( idx ) ).append( ", '" ); 74 to.append( p.getName() ).append( "', '" ); 75 to.append( p.getFirstName() ).append( "', " ); 76 to.append( Integer.toString( p.getPoints() ) ).append( ", " ); 77 to.append( Integer.toString( p.getLicenseID() ) ).append( ")" ); 78 } 79 80 } 81 | Popular Tags |