
January 15th, 2013, 04:46 PM
|
|
Registered User
|
|
Join Date: Jan 2013
Posts: 1
Time spent in forums: 17 m 10 sec
Reputation Power: 0
|
|
|
Problem connecting to a local postgresql database with JDBC
Hey,
Im a new user.
Please i am having problems connecting to my postgresql because i havent created a database before hand. But i do not know how to create or how to use the default template1 using java,and im stuck with the following code;
try{
Class.forName("org.postgresql.Driver");
}catch(ClassNotFoundException nf){
System.out.println(nf.getException());
}
System.out.println("Sucess");
String URL = "jdbc:postgresql:postgres";
Connection dbconn = null;
try {
dbconn = DriverManager.getConnection(URL);
} catch (SQLException e) {
System.out.println("Connection unsucessful!");
}
Please could i be hinted what exactly im doing wrong. Thanks
|