I've been working on a web project with Java EE and PostgreSQL and it runs perfectly. I tried moving it to another machine, but now it's not connecting to the database anymore.
I tried multiple solutions but nothing works so far:
- adding postgresql.jar to java build path
- moving it to the /lib file of tomcat server
Hers is my connection to database class:
public class DBConnexion {
private static Connection con=null;
private DBConnexion(){
try
{
try {
Class.forName("org.postgresql.Driver");
//getConnection(url:dataBase name, owner name , password)
con=(Connection)DriverManager.getConnection("jdbc:postgresql:septentrion", "postgres","123");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
catch(SQLException e1)
{
e1.printStackTrace();
}
}
public static Connection getInstance()
{
if(con==null)
new DBConnexion();
return con;
}
}