I use PostgreSQL to create my database and save my users list to it, when i try to connect db by java jdbc, i get error that say:
"java.sql.SQLException: invalid database address: jdbc:postgresql://localhost:5432/users".
i use "JDBC41 Postgresql Driver, Version 9.3-1102" from PostgreSQL website. and this is my code:
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class javaconnect {
private static Connection c = null;
public static Connection connectDb() {
try {
Class.forName("org.postgresql.Driver");
c = DriverManager.getConnection("jdbc:postgresql://localhost:5432/users", "postgres", "12345");
return c;
} catch (ClassNotFoundException | SQLException e) {
System.err.println(e.getClass().getName() + ": " + e.getMessage());
System.exit(0);
return null;
}
}
}
Thanks.