I have a microservice to read data from json and to save in local postgres but now i want to use azure postgres instead of local DB. When i try to connect using application properties im getting timeout error. Is there anything im missing?
In my connection security i have enabled Allow access to Azure services, i have also added my ip address in firewall rule and my SSl setting is disabled.
My application properties file for local postgres, which is working fine
spring.datasource.url=jdbc:postgresql://localhost:5432/MyDB
spring.datasource.username=postgres
spring.datasource.password=1234
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.platform=postgres
My application properties for azure postgres which is not working
spring.datasource.url : myapp.postgres.database.azure.com/test
spring.datasource.username: adminmyapp#myapp
spring.datasource.password: 123456
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.platform=postgres
Is my application properties correct?
I think you need to mention the driver as well,
spring.datasource.url=jdbc:postgresql://myapp.postgres.database.azure.com:5432/MyDB
Related
I am trying to use h2 database. Normally i used MySQL and ther is no problem but in h2 database not working in many to one . I couldn connect h2 console.
h2-console error
Error
Database "C:/Users/furka/test" not found, either pre-create it or allow remote
database creation (not recommended in secure environments) [90149-200] 90149/90149 (Help)
application.properties
#This part for H2 Database
server.port=8090
spring.datasource.url=jdbc:h2:mem:test
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
#enabling the H2 console
spring.h2.console.enabled=true
All code here: https://github.com/Furkan-Ahmet-Ozdemir/Spring-vet
I have setted up an Oracle cloud Autonomous transaction Processing (ATP) database, but when I am trying to connect it to my Java Spring boot application, it is throwing error:
java.sql.SQLRecoverableException: IO Error: An existing connection was forcibly closed by the remote host, Authentication lapse 0 ms."
I have correctly configured tnsnames.ora file and also sqlnet.ora file with proper location of credentials folder. But still getting above error.
My application.properties file is as below:
spring.datasource.url=jdbc:oracle:thin:#sampledb_high?TNS_ADMIN=E:\\Oracle cloud POC\\Wallet_sampleDB
spring.datasource.username=ADMIN
spring.datasource.password=********
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
Please let me know how to solve this.
Download the wallet from the UI
then unzip the wallet zip into a folder
for spring boot configuration
spring.datasource.url=jdbc:oracle:thin:#ddf9jcwvp9o3z7aa_high?TNS_ADMIN=/home/mintozzy/Downloads/Wallet_DDF9JCWVP9O3Z7AA
spring.datasource.username=READONLY_USER
spring.datasource.password=qw27dLDW4uDZf9D
You can see running spring boot petclinic example here for full properties
here you can see how to connect sql developer to cloud db.
I want to set db2 encryption password command when spring boot starts a connection with my db2. Basically some of the columns in my table are encrypted. I tried hibernate mapper #ColumnTransformer(read="decrypt_char(COLUMN_NAME,'password')",write="encrypt(?,'password')").
That does not work. After some look around I found that I have to set the encryption password with the following command when the database connection is established from spring boot application properties file.
SET ENCRYPTION PASSWORD ='password'(This is DB2 specific)
I dont see any way of setting this in spring boot. I believe there must be a property defined in application.properties which would set this. Currently I am just passing db2 connection as per following
spring.datasource.url=url
spring.datasource.username=username
spring.datasource.password=password
spring.datasource.driver-class-name=om.ibm.db2.jcc.DB2Driver
Any help is appreciated.
If the question is on how to pass the encryption password special registry variable setting via jdbc url, then the answer is: you need to add to the url something like the following:
...;specialRegisters=ENCRYPTION PASSWORD='password';
URL format for IBM Data Server Driver for JDBC and SQLJ type 4 connectivity
I am connected to dormitory subweb. I have 2 machines with external ip adresses. ( I am able to ping them or connect with them via SSH) Raspberry Pi running ubuntu mate where my Spring Boot server is hosted and other machine running Windows 10. Problem is that Spring server do not respond to requests from any source beside dormitory web (DW). I found that Issue is 8080 port closed. when I scan for open ports from beside DW I can only see 22 port opened, Computers inside DW see 8080 and 22 ports as opened and are able to respond HTTP server.
From what I have read here I have to set server.address property to be accessible from "outside"
My spring application.properties
#mysql test config
spring.datasource.url=jdbc:mysql://localhost:3306/springboot
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver`
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect
spring.jpa.hibernate.ddl-auto = update
spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.DefaultNamingStrategy
#initialization
spring.datasource.schema=classpath:/data/schema.sql
#server
server.address= my.adres.here
server.port = 8080
I am sure that sever reads this file properly.
I also tried turn off firewall temporarily
sudo ufw disable
to check if it blocks connection on this port but thats not the issue.
I am not sure where the real problem may be localized. Could it be something wrong with Spring Boot config? Or maybe it is some networking issue.
as #Robert Masen suggested problem was dormitory network blocking connection on 8080 port.
First of all, I created PostgreSQL DB in Heroku. I manually created my DB/schema/tables through pgAdmin remote access. I know I succeeded since it updated my row limit.
Now, I am deploying a Spring Boot application.
No DB props/credentials are found in my application.properties file since I am supposed to do this in Heroku Config Vars. For example, my DB username is janxgspmlpjgbn
Project builds successfully, however, in the logs I see that it has this exception.
2016-09-28 16:12:31.184 [ERROR] org.apache.juli.logging.DirectJDKLog.log:181 - Unable to create initial connections of pool.
2016-09-28T16:12:31.185772+00:00 app[web.1]: org.postgresql.util.PSQLException: FATAL: password authentication failed for user "u24453"
Question
Why does it fail for the user u24453 (by the way this user changes every time I redeploy) when in my Config Var, I typed the user janxgspmlpjgbn?
Edit
Here's how my Config Vars look right now:
u24453 is probably the OS user name (the one Heroku creates for your app as it runs on Ubuntu Linux).
I believe the Postgres Driver will use the OS username as your DB username by default (if a username is not provided). Thus, I suspect the DB username is not getting into the configuration properly.
In your application.yml you should have this:
spring:
datasource:
url: ${JDBC_DATABASE_URL}
username: ${JDBC_DATABASE_USERNAME}
password: ${JDBC_DATABASE_PASSWORD}
For more info see Connecting to Relational Databases on Heroku with Java