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 33 public class BulkWriteSingle implements BulkWriteStrategy 34 { 35 private final JdbcCar mCar; 36 37 40 public BulkWriteSingle( JdbcCar car ) 41 { 42 mCar = car; 43 } 44 45 48 public void savePilots(String tablename, Pilot[] p, int count, int index ) 49 { 50 for ( int i = 0; i < count; i++ ) 51 { 52 savePilot( tablename, p[i], index++ ); 53 } 54 } 55 56 57 61 private void savePilot( String tablename, Pilot p, int index ) 62 { 63 StringBuffer stmt = new StringBuffer ( "insert into "); 64 stmt.append(tablename); 65 stmt.append(" (id,Name,FrontName,Points,LicenseID) values ("); 66 stmt.append( Integer.toString( index ) ).append( ", '" ); 67 stmt.append( p.getName() ).append( "', '" ); 68 stmt.append( p.getFirstName() ).append( "', " ); 69 stmt.append( Integer.toString( p.getPoints() ) ).append( ", " ); 70 stmt.append( Integer.toString( p.getLicenseID() ) ).append( ")" ); 71 72 mCar.executeSQL( stmt.toString() ); 73 } 74 } 75 | Popular Tags |