FileWriter fileWriter = new FileWriter("items.sql");
fileWriter.append("DELETE FROM ITEMS\n");
fileWriter.flush();
for(int i=0; i < 5000; i++,itemId++){
StringBuffer sqlBuffer = new StringBuffer("INSERT INTO ITEMS (ID,NAME,DESCRIPTION,INITIAL_PRICE,QUANTITY,RESERVE_PRICE,BUY_NOW,NB_OF_BIDS,MAX_BID,START_DATE,END_DATE,SELLER,CATEGORY) VALUES (");
Item item = new Item();
int categoryId = generateCategoryId();
item.setId(new Integer(itemId));
this.items.put(item.getId(),item);
sqlBuffer.append(itemId);
sqlBuffer.append(",");
Category category = this.categories[categoryId-1];
sqlBuffer.append("'" + category.getName() + " #");
sqlBuffer.append(itemId);
sqlBuffer.append("','This incredible item is exactly what you need !',");
// Initial price
item.setInitialPrice((float) (Math.random()*15000));
sqlBuffer.append((int)item.getInitialPrice());
sqlBuffer.append(",");
// Qty
item.setQuantity((int)(Math.random()*10));
sqlBuffer.append(item.getQuantity());
sqlBuffer.append(",");
// Reserved price
item.setReservedPrice((float) (Math.random()*item.getInitialPrice()));
sqlBuffer.append((int)item.getReservedPrice());
sqlBuffer.append(",");
sqlBuffer.append("0,0,0,'2006-04-01 18:23:55','2060-01-01 18:23:55',");
sqlBuffer.append(generateUserId());
sqlBuffer.append(",");
sqlBuffer.append(categoryId);