前提・実現したいこと
webシステムを作成中です。
EC2インスタンスで、APサーバとDBサーバを作成しました。(RDSは使いません)
APサーバにはtomcatとJdbcドライバを、DBサーバにはPostgreSQLをインストールしています。
動かすと、DBにアクセスするところでエラーが発生します。
※ ローカルではうまく動いていました。
同じExceptionが発生している方の記事を探したのですが、探し方が悪いのか、ローカル環境で実施した際の事象が多く
解決策をみつけられませんでした。
以下の試したことのほかに確認するべき点をご存知の方がいらっしゃいましたら、教えていただきたいです。
試したこと・環境
DBサーバ側のセキュリティポート5432を設定しました。
接続先のIPアドレスを、DBサーバのIPv4 パブリック IPと、プライベートIPどちらも試しました。(ここは、どちらが正解なのでしょうか。。)
OS:RedHat7(どちらも)
言語:Java
FW:SpringFramework
DB:PostgreSQL
発生している問題・エラーメッセージ
org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is org.postgresql.util.PSQLException: Connection to xxx.xxx.xxx.xxx:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.
該当のソースコード
application-config.xmlの記述を抜粋します。
xml
1<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> 2<property name="driverClassName" value="org.postgresql.Driver" /> 3<property name="url" value="jdbc:postgresql://xxx.xxx.xxx.xxx:5432/▲▲db" /> 4<property name="username" value="▲▲▲▲▲▲" /> 5<property name="password" value="▲▲▲▲▲▲" /> 6</bean>
回答1件
あなたの回答
tips
プレビュー