sql - Java app: Connect to PostgreSQL database -


i attempting connect postgres sql database. normally, can connect going link:

test.ischool.testu.edu 

where connect phppgadmin entering credentials, , can connect database, testdb, selecting side.

here relevant java code:

    try {         class.forname("org.postgresql.driver");     } catch (classnotfoundexception e1) {         e1.printstacktrace();     }      string url = "jdbc:postgresql://test.ischool.testu.edu:5432/testdb";     string user = "testuser";     string pass = "testpassword";     connection db = null;     try {         db = drivermanager.getconnection(url,user,pass);     } catch (sqlexception e1) {         e1.printstacktrace();     } 

i receive following error:

org.postgresql.util.psqlexception: connection refused. check hostname , port             correct , postmaster accepting tcp/ip connections. 

i'm pretty sure doing wrong. assuming code correct (which i'm sure not case), connect database, need have .jar file inside remote directory, or can run locally? make difference?

i have connected database using following python code (this code inserted remote directly , run there):

    conn = psycopg2.connect("dbname=testdb user=testuser password=testpassword") 

the jdbc url using mysql:

jdbc:mysql://test.ischool.testu.edu:5432/testdb 

use 1 postgresql:

jdbc:postgresql://test.ischool.testu.edu:5432/testdb 

if changing doesn't please post exact error getting.


Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -