postgresql - Correct URL for connecting to java jdbc -
i'm having trouble setting connection database here , wondering may doing wrong. error follows:
exception in thread "main" java.sql.sqlexception: no suitable driver found jdbc:postgresql://168.16.1.128:5432/dbname @ java.sql.drivermanager.getconnection(drivermanager.java:689) @ java.sql.drivermanager.getconnection(drivermanager.java:270) @ sample.dbconnect.getconnection(dbconnect.java:21) @ sample.usertest.main(usertest.java:41) connecting class looks follows:
public class dbconnect { public java.sql.connection getconnection() throws sqlexception,illegalaccessexception, classnotfoundexception { java.sql.connection conn = null; string url = "jdbc:postgresql://168.16.1.128:5432/dbname"; conn = drivermanager.getconnection(url); system.out.println("connected database"); return conn; } } and heres gets called:
public class usertest { public static void main(string[] args) throws jsonexception, sqlexception, instantiationexception, illegalaccessexception, classnotfoundexception{ dbconnect db = new dbconnect(); db.getconnection(); } } i have feeling error may come way url written , if case can please explain me how write url? database doesnt require password , username connected to. hope can kind me.
thanks!
Comments
Post a Comment