こんにちは。
Android端末から、ローカルのPostgreSQLサーバーに接続しようとするのですが、
以下のエラーが出ます。
Something unusual has occurred to cause the driver to fail. Please report this exception.
ソースは
public class JDBCTest {
public static void main(String [] args) {
try {
try {
Class. forName("org.postgresql.Driver" );
Connection con =
DriverManager.getConnection ("jdbc:postgresql://localhost:5432/postgres",
"postgres",
"postgres");
} catch (Exception e) {
e. printStackTrace();
}
//以下略
ドライバのロードはできているのですが、getConnectionでエラーが発生します。
localhostを10.0.0.2にしても同じエラーでした。
mainメソッドはAndroidのメインアクティビティから呼び出しています。
postgreSQLのpg_hba.confのIPアドレスの許可も行っております。
Androidを介さず、Java単体で動作した場合は、エラーなく動作します。
データベースの中身も問題なく見れます。なのでホスト名、ユーザーID、パスワード間違っていないです。
しかしAndroid上で動作させると上記のエラーになります。
Android側の問題でしょうか?それともPostgreSQL側でしょうか?