开发者

How to connect to AWS RDS using java?

Can anyone poi开发者_开发技巧nt to tutorial where i can see step by step connecting to RDS from Java. I already downloaded SDK and was able to connect to S3. But the SDK doesnt have any example of connecting to RDS .. And also on web couldnt find anything useful...


got it , its simple connecting to any other jdbc with . The problem i had was that my ip address didnt have permission to access the DB. Which i resolved by putting the ip address in AWS console


This AWS tutorial uses RDS to store application data and also shows you the other requirements such as setting Inbound Rules.

https://github.com/awsdocs/aws-doc-sdk-examples/tree/master/javav2/usecases/creating_secure_spring_app


I mainly followed this guide, ignoring the .sql files, thymeleaf UI, "model.addAttribute("cities", cities);" part, and the html file: https://zetcode.com/springboot/postgresql/

My application.properties file looks like this

postgres.comment.aa=https://zetcode.com/springboot/postgresql/
spring.main.banner-mode=off
logging.level.org.springframework=ERROR

spring.jpa.hibernate.ddl-auto=none

spring.datasource.initialization-mode=always
spring.datasource.platform=postgres
spring.datasource.url=jdbc:postgresql://your-rds-url-here.us-east-1.rds.amazonaws.com:yourDbPortHere/postgres
spring.datasource.username=postgres
spring.datasource.password=<your db password here>

spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true

If you have custom schemas, you can append "?currentSchema=users" to the url:

spring.datasource.url=jdbc:postgresql://your-rds-url-here.us-east-1.rds.amazonaws.com:yourDbPortHere/postgres?currentSchema=users

Thanks to this SO answer for the schema: Is it possible to specify the schema when connecting to postgres with JDBC?

These other couple links also helped https://turreta.com/2015/03/01/how-to-specify-a-default-schema-when-connecting-to-postgresql-using-jdbc/

https://doc.cuba-platform.com/manual-latest/db_schema_connection.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜