Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This template is a Cloud Formation template, that has AWS Sam seamlessly mixed in | |
# It is extremely powerful as you will see! | |
# This is a template of Lambda & RDS, publically available (so no private VPC) | |
AWSTemplateFormatVersion: 2010-09-09 | |
Transform: AWS::Serverless-2016-10-31 # This is to tell cloudformation we need to transform this template, as it has SAM! | |
Description: Severless set up with an RDS | |
######## ### ######## ### ## ## | |
## ## ## ## ## ## ## ## ### ### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MyClusterManager { | |
private Session session; | |
private Cluster cluster; | |
@javax.annotation.PostConstruct | |
public void init() throws IOException | |
{ | |
cluster = createCluster(); // private method that builds a cluster | |
session = createSession(); // private method that builds a session |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static String WRITE_STATEMENT = "INSERT INTO avatars (id, image_type, avatar) VALUES (?,?,?);"; | |
private final BoundStatement writeStatement=writeStatement = session.prepare(WRITE_STATEMENT) | |
.setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM).bind(); | |
try { | |
BoundStatement stmt = driver.getWriteStatement(); | |
stmt.enableTracing(); | |
stmt.setLong("id", accountId); | |
stmt.setString("image_type", image.getType()); | |
stmt.setBytes("avatar", ByteBuffer.wrap(image.getBytes())); |