diff --git a/examples/SpringBootHikariDsqlExample/build.gradle.kts b/examples/SpringBootHikariDsqlExample/build.gradle.kts new file mode 100644 index 000000000..e3d88d1ff --- /dev/null +++ b/examples/SpringBootHikariDsqlExample/build.gradle.kts @@ -0,0 +1,28 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +plugins { + id("org.springframework.boot") version "2.7.0" + id("io.spring.dependency-management") version "1.1.7" +} + +dependencies { + implementation("org.springframework.boot:spring-boot-starter-data-jdbc") + implementation("org.springframework.boot:spring-boot-starter-web") + implementation("org.postgresql:postgresql:42.7.7") + implementation("software.amazon.awssdk:dsql:2.31.78") + implementation(project(":aws-advanced-jdbc-wrapper")) +} diff --git a/examples/SpringBootHikariDsqlExample/gradle.properties b/examples/SpringBootHikariDsqlExample/gradle.properties new file mode 100644 index 000000000..dc802102f --- /dev/null +++ b/examples/SpringBootHikariDsqlExample/gradle.properties @@ -0,0 +1,16 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"). +# You may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Do not publish the Jar file for this subproject +nexus.publish=false diff --git a/examples/SpringBootHikariDsqlExample/src/main/java/software/amazon/SpringBootHikariDsqlExample/ApiController.java b/examples/SpringBootHikariDsqlExample/src/main/java/software/amazon/SpringBootHikariDsqlExample/ApiController.java new file mode 100644 index 000000000..33c1d265f --- /dev/null +++ b/examples/SpringBootHikariDsqlExample/src/main/java/software/amazon/SpringBootHikariDsqlExample/ApiController.java @@ -0,0 +1,34 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package software.amazon.SpringBootHikariDsqlExample; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.core.JdbcTemplate; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class ApiController { + + @Autowired + private JdbcTemplate jdbcTemplate; + + @GetMapping(value = "/select1") + public Integer getOne() { + return jdbcTemplate.queryForObject("SELECT 1;", Integer.class); + } +} diff --git a/examples/SpringBootHikariDsqlExample/src/main/java/software/amazon/SpringBootHikariDsqlExample/SpringBootHikariExampleApplication.java b/examples/SpringBootHikariDsqlExample/src/main/java/software/amazon/SpringBootHikariDsqlExample/SpringBootHikariExampleApplication.java new file mode 100644 index 000000000..15e00c3ab --- /dev/null +++ b/examples/SpringBootHikariDsqlExample/src/main/java/software/amazon/SpringBootHikariDsqlExample/SpringBootHikariExampleApplication.java @@ -0,0 +1,27 @@ +/* + * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"). + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package software.amazon.SpringBootHikariDsqlExample; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringBootHikariExampleApplication { + public static void main(String[] args) { + SpringApplication.run(SpringBootHikariExampleApplication.class, args); + } +} diff --git a/examples/SpringBootHikariDsqlExample/src/main/resources/application.yml b/examples/SpringBootHikariDsqlExample/src/main/resources/application.yml new file mode 100644 index 000000000..442adaa7f --- /dev/null +++ b/examples/SpringBootHikariDsqlExample/src/main/resources/application.yml @@ -0,0 +1,14 @@ +spring: + datasource: + url: jdbc:aws-wrapper:postgresql://cluster-identifier.dsql.us-east-1.on.aws:5432/postgres + username: admin + driver-class-name: software.amazon.jdbc.Driver + hikari: + data-source-properties: + wrapperPlugins: iamDsql + wrapperDialect: pg + max-lifetime: 840000 + minimum-idle: 20 + maximum-pool-size: 20 + idle-timeout: 900000 + read-only: true diff --git a/examples/SpringBootHikariExample/build.gradle.kts b/examples/SpringBootHikariExample/build.gradle.kts index b53d94670..2c62924cb 100644 --- a/examples/SpringBootHikariExample/build.gradle.kts +++ b/examples/SpringBootHikariExample/build.gradle.kts @@ -6,7 +6,7 @@ * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 - *:eq + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. diff --git a/settings.gradle.kts b/settings.gradle.kts index 43f2d8169..67e56b0e5 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -28,6 +28,7 @@ include( "springhibernateonedatasource", "springhibernatetwodatasource", "springwildfly", + "springboothikaridsqlexample", "springboothikariexample", "springtxfailover", "vertxexample", @@ -44,6 +45,7 @@ project(":springhibernate").projectDir = file("examples/SpringHibernateExample") project(":springhibernateonedatasource").projectDir = file("examples/SpringHibernateBalancedReaderOneDataSourceExample") project(":springhibernatetwodatasource").projectDir = file("examples/SpringHibernateBalancedReaderTwoDataSourceExample") project(":springwildfly").projectDir = file("examples/SpringWildflyExample/spring") +project(":springboothikaridsqlexample").projectDir = file("examples/SpringBootHikariDsqlExample") project(":springboothikariexample").projectDir = file("examples/SpringBootHikariExample") project(":springtxfailover").projectDir = file("examples/SpringTxFailoverExample") project(":vertxexample").projectDir = file("examples/VertxExample")