1

Can anyone point 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...

Viccari
  • 8,299
  • 4
  • 38
  • 74
harshit
  • 7,659
  • 22
  • 66
  • 97

3 Answers3

3

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

harshit
  • 7,659
  • 22
  • 66
  • 97
0

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

smac2020
  • 2,706
  • 3
  • 13
  • 24
0

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

Dan Bitter
  • 161
  • 1
  • 10