Skip to content

Instantly share code, notes, and snippets.

@Double0negative
Created February 16, 2013 08:03
Show Gist options
  • Save Double0negative/4966025 to your computer and use it in GitHub Desktop.
Save Double0negative/4966025 to your computer and use it in GitHub Desktop.
class DatabaseDumper extends Thread{
PreparedStatement s;
public void run(){
s = dbman.createStatement("INSERT INTO "+SettingsManager.getSqlPrefix()+"blocks VALUES (?,?,?,?,?,?,?,?,?,?)");
while(queue.size()>0){
BlockData b = queue.remove(0);
try{
s.setInt(1, gameid);
s.setString(2,b.getWorld());
s.setInt(3, b.getPrevid());
s.setByte(4, b.getPrevdata());
s.setInt(5, b.getNewid());
s.setByte(6, b.getNewdata());
s.setInt(7, b.getX());
s.setInt(8, b.getY());
s.setInt(9, b.getZ());
s.setLong(10, new Date().getTime());
s.execute();
}catch(Exception e){
queue.add(b);
try {
dbman.getMysqlConnection().close();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
dbman.connect();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment