0
I need to include the variables urlLot, user and pass in the standalone so you don’t have to change the code and recompile every time I switch environments. Unfortunately I can’t think of any way to do that without having to change the whole structure of the project.
Follows how is my connection class with the database:
public Connection getConexao() throws SQLException{
String urlLot = "jdbc:postgresql://localhost:5432/teste";
String user = "postgres";
String pass = "123";
try {
if(this.connection == null || this.connection.isClosed()){
Class.forName("org.postgresql.Driver");
this.connection = DriverManager.getConnection(urlLot, user, pass);
PreparedStatement s = connection.prepareStatement("set search_path=db_teste;");
s.execute();
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return this.connection;
}
}