Setar schema JDBC + Postgres

1 resposta
G

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!!!

1 Resposta

W

http://www.guj.com.br/java/285107-postgresql—definir-o-schema-no-jdbc

Criado 20 de junho de 2013
Ultima resposta 20 de jun. de 2013
Respostas 1
Participantes 2