Se vc vai fazer para enteder o mecanismo e/ou estudar, creio que valha o esfor�o. Se for para utilizar em uma aplica��o "pra valer" d� uma olhada no dbcp do Apache, que � uma solu��o de pool de conex�o que vc consegue integrar ao tomcat, usar com hibernate, etc.
abra�os, wesley --- Miguel Henley <[EMAIL PROTECTED]> escreveu: > Conrad, > > Essa sua classe n�o est� implementando um pool de > conex�es com banco de dados. > Ha' algum tempo tamb�m precisei implementar um pool > mas achei um pronto na Internet muito bom. > Visite o site: > http://www.webdevelopersjournal.com/columns/connection_pool.html > leia o artigo e baixe o arquivo > DBConnectionManager.java -- muito interessante! > > []'s > Miguel. > ________________________________ > > De: Conrad Peres > [mailto:[EMAIL PROTECTED] > Enviada em: quarta-feira, 7 de julho de 2004 11:55 > Para: [EMAIL PROTECTED] > Assunto: [JUG-Petro] ConnectionPool > > > > Senhores, > > > > Estou fazendo meu Primeiro Connection Pool, gostaria > de algumas dicas de vcs, atualmente todas as > aplica��es est�o fazendo uma conex�o a cada request > do cliente, o que deixa a aplica��o lenta. > > > > Como eu fa�o pra usa o Connection Pool do Pr�prio > conteiner tomcat ou jboss? > > > > porque estou tentando instanciar um ConnectionPool e > esta dando erro de compila��o. > > > > > > Aguardo resposta > > Atenciosamente > > Conrad Peres. > > > > package util; > > //import java.io.PrintStream; > import java.sql.*; > > import javax.servlet.http.HttpSessionBindingEvent; > //import javax.servlet.http.HttpSessionBindingEvent; > //import > javax.servlet.http.HttpSessionBindingListener; > > public class ConnectionBean { > private Connection connection; > private Statement statement; > //private static final String driver = > "sun.jdbc.odbc.JdbcOdbcDriver"; > //private static final String dbURL = > "jdbc:odbc:TesteDix"; > //private static final String driver = > "com.pointbase.jdbc.jdbcUniversalDriver";/**/ > private static final String dbURL = > "172.16.1.19:1521:ORCL";/*BANCO CPD*/ > //private static final String dbURL = > "192.168.30.12:1521:unipro";/*BANCO > FORA!!!!!!!!!!!!!!!!!!!!!*/ > > private static final String login = > "unipro"; > private static final String password = > "unipro"; > > private static final String user = "unipro"; > > > public ConnectionBean( ) { > try { > // Connection conn = > DriverManager.getConnection ("jdbc:oracle:thin:@" + > database, user, password); > // DriverManager.registerDriver(new > oracle.jdbc.driver.OracleDriver());/**/ > > > //driver="oracle.jdbc.driver.OracleDriver()"; > //Class.forName( driver );/**/ > //connection = > DriverManager.getConnection( dbURL, login, password > ); > DriverManager.registerDriver(new > oracle.jdbc.driver.OracleDriver()); > connection = > DriverManager.getConnection ("jdbc:oracle:thin:@" + > dbURL, user, password); > > statement = connection.createStatement( > ); > //System.out.println("CB instanci�"); > } catch( SQLException sqlexception ) { > > System.err.println( "ConnectionBean: > driver not loaded" ); > //sqlexception.printStackTrace(); > connection = null; > } > catch( Exception e) { > System.err.println( "ConnectionBean: > driver unavailable" ); > connection = null; > > } > } > public Connection getConnection( ) { > return connection; > } > > public void commit( ) throws SQLException { > connection.commit( ); > } > > public void rollback( ) throws SQLException { > connection.rollback( ); > } > > public void setAutoCommit( boolean flag ) throws > SQLException { > connection.setAutoCommit( flag ); > } > > public boolean getAutoCommit( ) throws > SQLException { > return connection.getAutoCommit( ); > } > > public ResultSet executeQuery( String s ) throws > SQLException { > return statement.executeQuery( s ); > } > > public int executeUpdate( String s ) throws > SQLException { > return statement.executeUpdate( s ); > } > > public ResultSet prepareCallQuery( String s ) > throws SQLException { > java.sql.CallableStatement callablestatement > = connection.prepareCall( s ); > return callablestatement.executeQuery( ); > } > > public int prepareCallUpdate( String s ) throws > SQLException { > java.sql.CallableStatement callablestatement > = connection.prepareCall( s ); > return callablestatement.executeUpdate( ); > } > > public void valueBound( HttpSessionBindingEvent > httpsessionbindingevent ) { > System.err.println( "ConnectionBean: in the > valueBound method" ); > try { > if( connection == null || > connection.isClosed( ) ) { > connection = DriverManager.getConnection( dbURL, > login, password ); > statement = > connection.createStatement( ); > } > } catch( SQLException sqlexception ) { > connection = null; > } > } > > public void valueUnbound( HttpSessionBindingEvent > httpsessionbindingevent ) { > try { > connection.close( ); > } catch( SQLException sqlexception ) { > } finally { > connection = null; > } > } > > public void finalize( ) { > try { > statement.close( ); > connection.close( ); > === message truncated === _______________________________________________________ Yahoo! Mail agora com 100MB, anti-spam e antiv�rus gr�tis! http://br.info.mail.yahoo.com/ ------------------------ Yahoo! Groups Sponsor --------------------~--> Yahoo! Domains - Claim yours for only $14.70 http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/5cFolB/TM --------------------------------------------------------------------~-> Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/jug-petropolis/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
