System.setProperty("jdbc.drivers", "org.postgresql.Driver");
Connection conn = DriverManager.getConnection("jdbc:postgresql:////
127.0.0.1//Notes", "myun", "mypw");
Exception in thread "main" org.postgresql.util.PSQLException: The
connection attempt failed.
at
org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:
137)
at
org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:
66)
at
org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:
124)
at
org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:
30)
at
org.postgresql.jdbc3.Jdbc3Connection.<init>(Jdbc3Connection.java:24)
at org.postgresql.Driver.makeConnection(Driver.java:386)
at org.postgresql.Driver.connect(Driver.java:260)
at java.sql.DriverManager.getConnection(DriverManager.java:
582)
at java.sql.DriverManager.getConnection(DriverManager.java:
185)
at
com.cpsoft.mynotes.database.accounts.DatabaseAccount.main(DatabaseAccount.java:
17)
Caused by: java.net.UnknownHostException: /
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at java.net.Socket.<init>(Socket.java:366)
at java.net.Socket.<init>(Socket.java:180)
at org.postgresql.core.PGStream.<init>(PGStream.java:62)
at
org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:
77)
... 9 more
Java Result: 1
Your original syntax shows way too many slash characters.
> Connection conn = DriverManager.getConnection(
> "jdbc:postgresql:////127.0.0.1//Notes", "myun", "mypw");
I suspect this:
> System.setProperty("jdbc.drivers", "org.postgresql.Driver");
I've never done such a thing with JDBC code before. Initializing the driver
with Class.forName(), which is NOT a "test", btw, but how you initialize the
driver, has always sufficed.
Setting a System property in code is where you went wrong. The whole point of
System properties is that they are set by the *system*, and then read in code.
The typical approach to setting them is a "-D" parameter on the java command
line. This is, in fact, how you're supposed to use this particular property.
According to the documentation, it is used so that
> the JVM will attempt to load the driver as part of its initialization.
<http://jdbc.postgresql.org/documentation/83/load.html>
That means that since you didn't provide the value at the right time, it
wasn't available *during initialization*.
Just use Class.forName() to load the driver.
Try the correct number of slashes. I don't think the extra one after the IP
address hurts, but I really don't know about the one after the protocol. The
documentation sure doesn't indicate the use of four slashes.
You could also try specifying the port if you aren't using the 5432 default.
--
Lew
Also, Chase, you've been around long enough to know better:
Provide an SSCCE for God's sake!
--
Lew
Connection conn =
DriverManager.getConnection("jdbc:postgresql://localhost/Notes", "myun",
"mypw");
should work. And you will need to specify the host if it
is not localhost.
Arne
BACKslashes.
If it doesn't work with two slashes, check whether eth0 is up.
--
DF.
to reply privately, change the top-level domain
in the FROM address from "invalid" to "net"
That is necessary for \ not for /.
Arne