im facing problems with the following code..
initially the jdbc driver was not getting
registered...that problem is rectified...now im facing
problems connecting with the database..
******************************************************import
java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;
public class Example1 {
public static void main(String[] argv) {
System.out.println("Checking if Driver is registered
with DriverManager.");
try {
Class.forName("org.postgresql.Driver");
} catch (ClassNotFoundException cnfe) {
System.out.println("Couldn't find the driver!");
System.out.println("Let's print a stack trace, and
exit.");
cnfe.printStackTrace();
System.exit(1);
}
System.out.println("Registered the driver ok, so
let's make a connection.");
Connection c = null;
try {
// The second and third arguments are the username
and password,
// respectively. They should be whatever is
necessary to connect
// to the database.
c =
DriverManager.getConnection("jdbc:postgresql://localhost/ids","postgres","123456");
} catch (SQLException se) {
System.out.println("Couldn't connect: print out a
stack trace and exit.");
se.printStackTrace();
System.exit(1);
}
if (c != null)
System.out.println("Hooray! We connected to the
database!");
else
System.out.println("We should never get here.");
}
}
*****************************************************
*****************************************************
The error that im geting is
*****************************************************
Checking if Driver is registered with DriverManager.
Registered the driver ok, so let's make a connection.
Couldn't connect: print out a stack trace and exit.
org.postgresql.util.PSQLException: A connection error
has occurred: org.postgresql.util.PSQLException:
FATAL: Ident authentication failed for user "postgres"
at
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnectionV3(AbstractJdbc1Connection.java:337)
at
org.postgresql.jdbc1.AbstractJdbc1Connection.openConnection(AbstractJdbc1Connection.java:214)
at org.postgresql.Driver.connect(Driver.java:139)
at
java.sql.DriverManager.getConnection(libgcj.so.7rh)
at
java.sql.DriverManager.getConnection(libgcj.so.7rh)
at Example1.main(Example1.java:27)
******************************************************
kindly help me with this.... my final yr project
is stuck up because of this...
...Parul
Send a FREE SMS to your friend's mobile from Yahoo! Messenger. Get it now at http://in.messenger.yahoo.com/