I have postgresql 8.1 installed
db name is 'mydb'
user name is 'test'
password is 'test'
I can conect to this db by psql
$psql -U test mydb
But I cannon connect by jdbc
The error
db name is 'mydb'
user name is 'test'
password is 'test'
I can conect to this db by psql
$psql -U test mydb
But I cannon connect by jdbc
Code:
import java.io.*;
import java.sql.*;
public class Sample {
Connection conn;
Statement stmt;
public Sample() throws ClassNotFoundException, FileNotFoundException, IOException, SQLException {
Class.forName("org.postgresql.Driver");
conn = DriverManager.getConnection("jdbc:postgresql:mydb", "test", "test");
stmt = conn.createStatement();
stmt.close();
conn.close();
}
public static void main(String args[]) {
try {
Sample test = new Sample();
} catch(Exception exc) {
System.err.println("Exception caught.\n" + exc);
exc.printStackTrace();
}
}
}
The error
Code:
$ java -cp /usr/local/share/java/classes/postgresql.jar:. Sample
Exception caught.
org.postgresql.util.PSQLException: FATAL: missing or erroneous pg_hba.conf file
org.postgresql.util.PSQLException: FATAL: missing or erroneous pg_hba.conf file
at org.postgresql.core.v3.ConnectionFactoryImpl.doAuthentication(ConnectionFactoryImpl.java:275)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:94)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:65)
at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:116)
at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:30)
at org.postgresql.jdbc3g.Jdbc3gConnection.<init>(Jdbc3gConnection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:369)
at org.postgresql.Driver.connect(Driver.java:245)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:171)
at Sample.<init>(Sample.java:11)
at Sample.main(Sample.java:21)