Skip to content

Instantly share code, notes, and snippets.

@maxant
Last active August 29, 2015 14:12
Show Gist options
  • Save maxant/c013fa6e8cc99bca5d52 to your computer and use it in GitHub Desktop.
Save maxant/c013fa6e8cc99bca5d52 to your computer and use it in GitHub Desktop.
Extra bits related to persistence
private static final String SQL = "INSERT INTO SALES (BUYER_NAME, SELLER_NAME, PRODUCT_ID, PRICE, QUANTITY, PO_ID, SO_ID) VALUES (?, ?, ?, ?, ?, ?, ?)";
private static final ConnectionPool<MySQLConnection> POOL;
static {
Duration connectTimeout = Duration.apply(5.0, TimeUnit.SECONDS);
Duration testTimeout = Duration.apply(5.0, TimeUnit.SECONDS);
Configuration configuration = new Configuration("root", Main.DB_HOST, 3306, Option.apply("password"), Option.apply("TRADER"), io.netty.util.CharsetUtil.UTF_8, 16777216, PooledByteBufAllocator.DEFAULT, connectTimeout, testTimeout);
MySQLConnectionFactory factory = new MySQLConnectionFactory(configuration);
POOL = new ConnectionPool<MySQLConnection>(factory, new PoolConfiguration(1000, 4, 1000, 4000), Main.system.dispatcher());
}
private static interface PersistenceComplete {
void apply(Throwable failure);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment