public void run()throws Exception{
File file = new File("d:" + File.separator + "contact.txt") ;
File file2 = new File("d:" + File.separator + "contact_field.txt") ;
Writer out = null ;
Writer out2 = null ;
out = new OutputStreamWriter(new FileOutputStream(file)) ;
out2 = new OutputStreamWriter(new FileOutputStream(file2)) ;
int id=1;
int contact_field_id=1;
for(int i=1;i<=50;i++){
Connection conn = DriverManager.getConnection("jdbc:mysql://172.17.65.100:3306/pim"+i,"testuser","testpass");
int offset = 0;
int limit = 1000;
List<Contact> list=findAllContact(conn,offset,limit);
while(list.size() > 0){
for(Contact c :list){
List<ContactField> listf=findAllContactFieldByContactId(conn, c.getId());
String sql="INSERT INTO contact (contact_id, created, updated, deleted, operation, subscriber_id, edit_by, is_star, version, create_version, home_phone," +
" work_phone, home_email, work_email, display_name, mobile_phone, photo, client_id, device_id, name_firstChar, name_pinyin, is_private, contact_subscriber_id," +
"modify_device_id, uuid, crc, adler, photo_length, namePhone_md5, checksum_version) " +
"VALUES ("+id+",'"+c.getCreated()+"','"+c.getUpdated()+"',"+c.getDeleted()+","+c.getOperation()+","+c.getSubscriberId()+",'"+c.getEditBy()+"'," +
""+c.getIsStar()+","+c.getVersion()+","+c.getCreateVersion()+",'"+c.getHomePhone()+"','"+c.getWorkPhone()+"','"+c.getHomeEmail()+"','"+c.getWorkEmail()+"'," +
"'"+c.getDisplayName()+"','"+c.getMobilePhone()+"','"+c.getPhoto()+"',"+c.getClientId()+",'"+c.getDeviceId()+"','"+c.getNameFirstChar()+"','"+c.getNamePinYin()+"'," +
""+c.getIsPrivate()+","+c.getContactSubscriberId()+",'"+c.getModifyDeviceId()+"','"+c.getUuid()+"','"+c.getCrc()+"','"+c.getAdler()+"',"+c.getPhotoLength()+"," +
"'"+c.getNamePhonemd5()+"',"+c.getChecksumversion()+");";
out.write(sql);
out.write("\n");
for(ContactField f : listf){
f.setContactId(Long.valueOf(id));
String sql2="INSERT INTO contact_field(field_id, contact_id, mime_type, flag, created, updated, create_version, version, operation, edit_by, data, deleted, client_id, device_id, deleted_contact, uuid)" +
"VALUES("+contact_field_id+","+f.getContactId()+",'"+f.getMimeType()+"','"+f.getFlag()+"','"+f.getCreated()+"','"+f.getUpdated()+"',"+f.getCreateVersion()+"," +
""+f.getVersion()+","+f.getOperation()+",'"+f.getEditBy()+"','"+f.getData()+"',"+f.getDeleted()+","+f.getClientId()+",'"+f.getDeviceId()+"',"+f.getDeletedContact()+",'"+f.getUuid()+"');";
out2.write(sql2);
out2.write("\n");
contact_field_id++;
}
id++;
}
offset+=limit;
list=findAllContact(conn,offset,limit);
}
}
out.close();
out2.close();
}
File file = new File("d:" + File.separator + "contact.txt") ;
File file2 = new File("d:" + File.separator + "contact_field.txt") ;
Writer out = null ;
Writer out2 = null ;
out = new OutputStreamWriter(new FileOutputStream(file)) ;
out2 = new OutputStreamWriter(new FileOutputStream(file2)) ;
int id=1;
int contact_field_id=1;
for(int i=1;i<=50;i++){
Connection conn = DriverManager.getConnection("jdbc:mysql://172.17.65.100:3306/pim"+i,"testuser","testpass");
int offset = 0;
int limit = 1000;
List<Contact> list=findAllContact(conn,offset,limit);
while(list.size() > 0){
for(Contact c :list){
List<ContactField> listf=findAllContactFieldByContactId(conn, c.getId());
String sql="INSERT INTO contact (contact_id, created, updated, deleted, operation, subscriber_id, edit_by, is_star, version, create_version, home_phone," +
" work_phone, home_email, work_email, display_name, mobile_phone, photo, client_id, device_id, name_firstChar, name_pinyin, is_private, contact_subscriber_id," +
"modify_device_id, uuid, crc, adler, photo_length, namePhone_md5, checksum_version) " +
"VALUES ("+id+",'"+c.getCreated()+"','"+c.getUpdated()+"',"+c.getDeleted()+","+c.getOperation()+","+c.getSubscriberId()+",'"+c.getEditBy()+"'," +
""+c.getIsStar()+","+c.getVersion()+","+c.getCreateVersion()+",'"+c.getHomePhone()+"','"+c.getWorkPhone()+"','"+c.getHomeEmail()+"','"+c.getWorkEmail()+"'," +
"'"+c.getDisplayName()+"','"+c.getMobilePhone()+"','"+c.getPhoto()+"',"+c.getClientId()+",'"+c.getDeviceId()+"','"+c.getNameFirstChar()+"','"+c.getNamePinYin()+"'," +
""+c.getIsPrivate()+","+c.getContactSubscriberId()+",'"+c.getModifyDeviceId()+"','"+c.getUuid()+"','"+c.getCrc()+"','"+c.getAdler()+"',"+c.getPhotoLength()+"," +
"'"+c.getNamePhonemd5()+"',"+c.getChecksumversion()+");";
out.write(sql);
out.write("\n");
for(ContactField f : listf){
f.setContactId(Long.valueOf(id));
String sql2="INSERT INTO contact_field(field_id, contact_id, mime_type, flag, created, updated, create_version, version, operation, edit_by, data, deleted, client_id, device_id, deleted_contact, uuid)" +
"VALUES("+contact_field_id+","+f.getContactId()+",'"+f.getMimeType()+"','"+f.getFlag()+"','"+f.getCreated()+"','"+f.getUpdated()+"',"+f.getCreateVersion()+"," +
""+f.getVersion()+","+f.getOperation()+",'"+f.getEditBy()+"','"+f.getData()+"',"+f.getDeleted()+","+f.getClientId()+",'"+f.getDeviceId()+"',"+f.getDeletedContact()+",'"+f.getUuid()+"');";
out2.write(sql2);
out2.write("\n");
contact_field_id++;
}
id++;
}
offset+=limit;
list=findAllContact(conn,offset,limit);
}
}
out.close();
out2.close();
}