Demo entry 6688602

bla

   

Submitted by anonymous on Jan 03, 2018 at 15:12
Language: Java. Code size: 964 Bytes.

import java.util.Arrays;
import java.util.List;

public class MigrationDemo {

	public static void main(String[] args) {
		List<String> databases = Arrays.asList("DB1", "DB2", "DB3", "DB4", "DB5");

		IMigration myMigration = new MyMigration();
		databases.parallelStream().forEach(myMigration::apply);
	}


	interface IMigration {
		void apply(String database);
	}

	static class MyMigration implements IMigration {

		private String preparedStatement;

		@Override
		public void apply(String database) {
			// pretend we just prepared a SQL statement
			preparedStatement = String.format("UPDATE %s.player SET new_generated_field = ?", database);

			for (int i = 0; i < 10000; i++) {
				// pretend we generated a meaningful value
				double generatedValue = Math.random();
				// pretend we're now substituting and executing
				System.out.println(preparedStatement.replace("?", String.valueOf(generatedValue)));
			}
		}
	}
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).