Re: properly way to lookup a java.sql.Connection from the connection pool
Hi Christopher, Christopher Tava wrote: dear ojb user group, could you kindly tell me the properly way to look a connection from the connection pool? i have used the following call, but i get a socked closed exception. Connection conn = pBroker.serviceConnectionManager().getConnection(); 2004-01-27 10:45:46,609 [RMI TCP Connection(126)-162.86.116.94] ERROR [com.server.TBean] java.sql.SQLException: Io exception: Socket closed That's the right way to handle connections within OJB. This method returns a connection from the ConnectionFactory (e.g. connection-pool impl). pBroker.serviceConnectionManager().releaseConnection(); cleanup used connection (Never do a con.close() call!!) If you lookup the connection within a tx, it's not allowed to do connection cleanup. If you don't do any connection cleanup, at the latest connection was released on PB.close() call. So your problem occur, because you close used connections or the connection is get timed out. To avoid last, if your DB support reconnect of timed out connection enable it or use a 'validationQuery' in jdbc-connection-descriptor to do a real connection check before Connection was returned from pool. regards, Armin your assistance is much appreciated, chris - Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: properly way to lookup a java.sql.Connection from the connection pool
Hi, I don't know if this method is well but I use it : ClassDescriptor classD = broker.getClassDescriptor(DualBO.class); JdbcConnectionDescriptor jcd = classD.getConnectionDescriptor(); //Creation of the connection java.sql.Connection connection = null; try { //Initialisation of the JDBC driver Class.forName(jcd.getDriver()); //connection to the database String url = jcd.getProtocol() + ":" + jcd.getSubProtocol() + ":" + jcd.getDbAlias(); connection = java.sql.DriverManager.getConnection(url, jcd.getUserName(), jcd.getPassWord()); } catch (ClassNotFoundException e) { log.error("the driver was not found : ", e); throw new DatabaseException(e); } catch (java.sql.SQLException e) { log.error("No connection to the database : ", e); throw new DatabaseException(e); } The only class who was not used here is DualBO.class, it is the table Dual (I think you can replace by an other table) I have already a connection to the database via broker to (that's him which make the link for get the connection). Hope it can help. -Message d'origine- De : Christopher Tava [mailto:[EMAIL PROTECTED] Envoye : mardi 27 janvier 2004 17:24 A : [EMAIL PROTECTED] Objet : properly way to lookup a java.sql.Connection from the connection pool dear ojb user group, could you kindly tell me the properly way to look a connection from the connection pool? i have used the following call, but i get a socked closed exception. Connection conn = pBroker.serviceConnectionManager().getConnection(); 2004-01-27 10:45:46,609 [RMI TCP Connection(126)-162.86.116.94] ERROR [com.server.TBean] java.sql.SQLException: Io exception: Socket closed your assistance is much appreciated, chris - Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it! - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
properly way to lookup a java.sql.Connection from the connection pool
dear ojb user group, could you kindly tell me the properly way to look a connection from the connection pool? i have used the following call, but i get a socked closed exception. Connection conn = pBroker.serviceConnectionManager().getConnection(); 2004-01-27 10:45:46,609 [RMI TCP Connection(126)-162.86.116.94] ERROR [com.server.TBean] java.sql.SQLException: Io exception: Socket closed your assistance is much appreciated, chris - Do you Yahoo!? Yahoo! SiteBuilder - Free web site building tool. Try it!