Diga pessoal, ja postei uma mensagem desta aqui no forum mas ainda não tive sucesso, o problema foi o seguinte:
Vou tentar passar também o que estou utilizando.
No server.xml tenho:
<Context path="/sistemas" docBase="sistemas" debug="0" reloadable="true" crossContext="true">
<Resource name="jdbc/gerencial" auth="Container" type="javax.sql.DataSource"/>
<ResourceParams name="jdbc/gerencial">
<parameter>
<name>factory</name>
<value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
</parameter>
<parameter>
<name>driverClassName</name>
<value>oracle.jdbc.driver.OracleDriver</value>
</parameter>
<parameter>
<name>url</name>
<value>jdbc:oracle:thin:@dbcluster:1521:dbprod</value>
</parameter>
<parameter>
<name>username</name>
<value>usuario</value>
</parameter>
<parameter>
<name>password</name>
<value>senha</value>
</parameter>
<parameter>
<name>removeAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>removeAbandonedTimeout</name>
<value>300</value>
</parameter>
<parameter>
<name>logAbandoned</name>
<value>true</value>
</parameter>
<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>
<parameter>
<name>maxIdle</name>
<value>3</value>
</parameter>
<parameter>
<name>maxWait</name>
<value>30000</value>
</parameter>
</ResourceParams>
</Context>
E no web.xml:
<resource-ref>
<description>Pool de conexoes da WebCoruripe</description>
<res-ref-name>jdbc/gerencial</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>
E a minha classe eh a seguinte:
public class ConnectionBD implements servicos.comunicacao.Connection{
private static DataSource ds;
private java.sql.Connection con;
private Statement statement;
private String driver;
private String url;
private String user;
private String password;
private String user;
private String password;
/** Faz a conexão com o banco. */
public synchronized void connect() throws java.sql.SQLException {
try{
if (!this.isConnected()){
this.showOperation("Efetuando conexão com o banco...");
this.statement = null;
this.preparedStatement = null;
this.lastComandPrepared = null;
if (this.ds == null){
Context ctx = new InitialContext();
this.ds = (DataSource)ctx.lookup("java:comp/env/jdbc/gerencial");
}
this.con = this.ds.getConnection();
System.out.println("Conexão: " + this.con);
}
this.showOperation("Ok.");
}catch(Exception e){
throw this.makeSQLException(e, null);
}
}
/** Fecha a conexão com o banco */
public synchronized boolean disConnect() {
try{
if (this.isConnected()){
this.showOperation("Efetuando desconexão...");
if (this.statement != null){
this.statement.close();
this.statement = null;
}
if (this.preparedStatement != null){
this.preparedStatement.close();
this.preparedStatement = null;
}
this.lastComandPrepared = null;
this.con.close();
this.showOperation("Ok.");
System.out.println("Desconexão: " + this.con);
return true;
}else
return false;
}catch(Exception e){
this.showOperation(e.toString());
return false;
}
}
/** Retorna verdadeiro se a conexão esta aberta */
public boolean isConnected() throws java.sql.SQLException {
try{
this.showOperation("Verificando conexão...");
boolean conectado;
if (con == null){
conectado = false;
}else{
conectado = ! con.isClosed();
}
this.showOperation("Ok.");
return conectado;
}catch(Exception e){
throw this.makeSQLException(e, null);
}
}
/** Executa a instrução SQL:INSERT, UPDATE,... com exceção do SELECT */
public int executeUpdate(String sql) throws java.sql.SQLException {
try{
this.showOperation("Executando o comando sql: [" + sql + "]...");
if (this.statement == null)
this.statement = con.createStatement();
this.showOperation("Ok.");
return this.statement.executeUpdate(sql);
}catch(Exception e){
throw this.makeSQLException(e, sql);
}
}
/** Executa uma consulta SQL */
public ResultSet executeQuery(String sql) throws java.sql.SQLException {
try{
this.showOperation("Executando consulta: [" + sql + "]...");
if (this.statement == null)
this.statement = con.createStatement();
this.showOperation("Ok.");
return this.statement.executeQuery(sql);
}catch(Exception e){
throw this.makeSQLException(e, sql);
}
}
}
Desculpem o excesso de código mas foi o único jeito de deixar mais claro o meu problema.
Se alguem poder ajudar…
At+