File tree Expand file tree Collapse file tree 2 files changed +3
-7
lines changed
labs/unicorn-store/infrastructure/db-setup
src/main/java/com/amazon/aws Expand file tree Collapse file tree 2 files changed +3
-7
lines changed Original file line number Diff line number Diff line change 4747 <artifactId >postgresql</artifactId >
4848 <version >42.7.4</version >
4949 </dependency >
50- <dependency >
51- <groupId >commons-io</groupId >
52- <artifactId >commons-io</artifactId >
53- <version >2.17.0</version >
54- </dependency >
5550 <dependency >
5651 <groupId >com.amazonaws</groupId >
5752 <artifactId >aws-lambda-java-core</artifactId >
Original file line number Diff line number Diff line change 55import com .amazonaws .services .lambda .runtime .events .APIGatewayProxyRequestEvent ;
66import com .amazonaws .services .lambda .runtime .events .APIGatewayProxyResponseEvent ;
77import com .fasterxml .jackson .jr .ob .JSON ;
8- import org .apache .commons .io .IOUtils ;
98import org .slf4j .Logger ;
109import org .slf4j .LoggerFactory ;
1110import software .amazon .awssdk .auth .credentials .EnvironmentVariableCredentialsProvider ;
1716import software .amazon .awssdk .services .secretsmanager .model .GetSecretValueRequest ;
1817
1918import java .io .IOException ;
19+ import java .nio .charset .StandardCharsets ;
2020import java .sql .DriverManager ;
2121import java .time .Duration ;
2222import java .util .concurrent .ExecutionException ;
@@ -65,7 +65,8 @@ public APIGatewayProxyResponseEvent handleRequest(final APIGatewayProxyRequestEv
6565 try (var connection = DriverManager .getConnection (databaseConnection , databaseUser , databasePassword )) {
6666 try (var statement = connection .createStatement ()) {
6767 try (var sqlFile = getClass ().getClassLoader ().getResourceAsStream ("setup.sql" )) {
68- statement .executeUpdate (IOUtils .toString (sqlFile ));
68+ String sqlContent = new String (sqlFile .readAllBytes (), StandardCharsets .UTF_8 );
69+ statement .executeUpdate (sqlContent );
6970 return new APIGatewayProxyResponseEvent ()
7071 .withStatusCode (200 )
7172 .withBody ("DB Setup successful" );
You can’t perform that action at this time.
0 commit comments