Bom dia galera,
Caiu um sistema legado no meu colo e o intuito agora e passar tudo que esta em mysql para o postgres.
Como faço para setar o schema sorteio?
Por exemplo o banco de dados é sistemas, o nome do meu schema é sorterio
package permuta.DAO;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class BaseDAO {
protected Connection connection;
protected PreparedStatement ps;
public BaseDAO() {
}
public Connection getConexao() throws SQLException{
String urlLot = "jdbc:postgresql://localhost:5432/sistemas";
String user = "xxx";
String pass = "xxx";
try {
if(this.connection == null || this.connection.isClosed()){
Class.forName("org.postgresql.Driver");
this.connection = DriverManager.getConnection(urlLot, user, pass);
}
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return this.connection;
}
public void fechaConexao(){
try {
if (!this.connection.isClosed()) {
this.connection.close();
}
} catch (SQLException e) {
e.printStackTrace();
}
}
@Override
protected void finalize() throws Throwable {
super.finalize();
if (!connection.isClosed()) {
connection.close();
}
}
}
Obrigado!!!