Connection problem
Hello Everyone, I am facing a serious problem with Connection in OJB. The situation this error occurs is when the site has been inactive for quite some time i.e. No web visitors are present and when a user visits the site and tries to login I get Exception from: [-- LoginAction.java --] org.apache.ojb.broker.PersistenceBrokerException: Used ConnectionManager instance could not obtain a connection and at time it throws Communication link failure. If I refresh the page this error is gone or if i restart tomcat or mysql this problem is resolved. I can not expect the sys admin to restart the tomcat or mysql if it is inactive for certain amount of time. What is problem in this case and how can I solve this. Please help Thanks Bikram B Kapoor - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection problem
That's probably a configuration issue with the MySQL JDBC driver or the MySQL server as MySQL shuts down the connection after a certain period of inactivity. You can try to specify some properties in the jdbc url, e.g. autoReconnect, see here for details: http://dev.mysql.com/doc/connector/j/en/cj-driver-classname.html#id2624462 Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
OJB Listener :: Best practise
Hi everybody, I need a simple Listener which methods get called after insert, update and delete. I just found Listener for Transaction stuff in the API. Any suggestions? GreetZ Nils
AppServer: When does a Transaction start/end?
hello list, I would like to clearify, how ojb and jboss handle a transaction in a managed environment exactly. I'm using Jboss and the PersistenceBrokerFactorySyncImpl. I assume, it's is like that: void func() { PersistenceBroker broker = getBroker(); -- here the transaction starts!? try { broker.dosomething(); } catch (PersistenceBrokerException e) { throw new EJBException(e); -- here the transaction ends: ROLLBACK (appserver tracks the EJBException) } -- here the transaction ends: COMMIT (broker is being released) } thanks for your help! andreas
RE: OJB Listener :: Best practise
Here's a quick off the cuff list of steps for listeners that work for both ODMG PB, based on what we do here. a) Create your own persistence broker factory, extending PersistenceBrokerFactoryDefaultImpl b) Override createNewBrokerInstance(PBKey key) and add your listener(s) http://db.apache.org/ojb/api/org/apache/ojb/broker/core/PersistenceBrokerFac toryDefaultImpl.html#createPersistenceBroker e.g. (One listener instance for all brokers ) protected PersistenceBroker createNewBrokerInstance(PBKey key) throws PBFactoryException { PersistenceBroker newBrokerInstance = super.createNewBrokerInstance(key); newBrokerInstance.addListener(yourListenerInstance) return newBrokerInstance; } c) Change PersistenceBrokerFactoryClass entry in OJB.properties to point to your new class e.g. ##PersistenceBrokerFactoryClass=org.apache.ojb.broker.core.PersistenceBroker FactoryDefaultImpl PersistenceBrokerFactoryClass=com.mycompany.MyBrokerFactory d) There is no d) Cheers, Charles. -Original Message- From: Nils Liebelt [mailto:[EMAIL PROTECTED] Sent: 07 April 2005 13:55 To: 'OJB Users List' Cc: [EMAIL PROTECTED] Subject: OJB Listener :: Best practise Hi everybody, I need a simple Listener which methods get called after insert, update and delete. I just found Listener for Transaction stuff in the API. Any suggestions? GreetZ Nils ___ HPD Software Ltd. - Helping Business Finance Business Email terms and conditions: www.hpdsoftware.com/disclaimer - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: OJB Listener :: Best practise
Charles, Do you know if listener state events (afterBegin, afterCommit, ...) are going to be invoked in managed environment? Thank you, Max. -Original Message- From: Charles Anthony [mailto:[EMAIL PROTECTED] Sent: Thursday, April 07, 2005 9:12 AM To: 'OJB Users List' Cc: [EMAIL PROTECTED] Subject: RE: OJB Listener :: Best practise Here's a quick off the cuff list of steps for listeners that work for both ODMG PB, based on what we do here. a) Create your own persistence broker factory, extending PersistenceBrokerFactoryDefaultImpl b) Override createNewBrokerInstance(PBKey key) and add your listener(s) http://db.apache.org/ojb/api/org/apache/ojb/broker/core/PersistenceBrokerFac toryDefaultImpl.html#createPersistenceBroker e.g. (One listener instance for all brokers ) protected PersistenceBroker createNewBrokerInstance(PBKey key) throws PBFactoryException { PersistenceBroker newBrokerInstance = super.createNewBrokerInstance(key); newBrokerInstance.addListener(yourListenerInstance) return newBrokerInstance; } c) Change PersistenceBrokerFactoryClass entry in OJB.properties to point to your new class e.g. ##PersistenceBrokerFactoryClass=org.apache.ojb.broker.core.PersistenceBroker FactoryDefaultImpl PersistenceBrokerFactoryClass=com.mycompany.MyBrokerFactory d) There is no d) Cheers, Charles. -Original Message- From: Nils Liebelt [mailto:[EMAIL PROTECTED] Sent: 07 April 2005 13:55 To: 'OJB Users List' Cc: [EMAIL PROTECTED] Subject: OJB Listener :: Best practise Hi everybody, I need a simple Listener which methods get called after insert, update and delete. I just found Listener for Transaction stuff in the API. Any suggestions? GreetZ Nils ___ HPD Software Ltd. - Helping Business Finance Business Email terms and conditions: www.hpdsoftware.com/disclaimer - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: OJB Listener :: Best practise
Hi, I've never used OJB in managed environment, but looking at the PersistenBrokerFactorySyncImpl (http://cvs.apache.org/viewcvs.cgi/db-ojb/src/java/org/apache/ojb/broker/cor e/PersistenceBrokerFactorySyncImpl.java?view=markup) specifically, the PersistenceBrokerSyncImpl inner class, it certainly seems to implement to the Synchronsation and pass on the calls to the delegating PB - which would intern invoke the listeners. However, the tricky bit would be where to add the listeners - as you'd have to subclass the PersistenceBrokerFactorySyncImpl broker factory. Armin seems to be the man to do with using PB in a managed environment; I'll have to leave you in his hands for where to add the listeners. Charles. -Original Message- From: Vesely, Max [IT] [mailto:[EMAIL PROTECTED] Sent: 07 April 2005 14:25 To: OJB Users List Subject: RE: OJB Listener :: Best practise Charles, Do you know if listener state events (afterBegin, afterCommit, ...) are going to be invoked in managed environment? Thank you, Max. -Original Message- From: Charles Anthony [mailto:[EMAIL PROTECTED] Sent: Thursday, April 07, 2005 9:12 AM To: 'OJB Users List' Cc: [EMAIL PROTECTED] Subject: RE: OJB Listener :: Best practise Here's a quick off the cuff list of steps for listeners that work for both ODMG PB, based on what we do here. a) Create your own persistence broker factory, extending PersistenceBrokerFactoryDefaultImpl b) Override createNewBrokerInstance(PBKey key) and add your listener(s) http://db.apache.org/ojb/api/org/apache/ojb/broker/core/PersistenceBrokerFac toryDefaultImpl.html#createPersistenceBroker e.g. (One listener instance for all brokers ) protected PersistenceBroker createNewBrokerInstance(PBKey key) throws PBFactoryException { PersistenceBroker newBrokerInstance = super.createNewBrokerInstance(key); newBrokerInstance.addListener(yourListenerInstance) return newBrokerInstance; } c) Change PersistenceBrokerFactoryClass entry in OJB.properties to point to your new class e.g. ##PersistenceBrokerFactoryClass=org.apache.ojb.broker.core.PersistenceBroker FactoryDefaultImpl PersistenceBrokerFactoryClass=com.mycompany.MyBrokerFactory d) There is no d) Cheers, Charles. -Original Message- From: Nils Liebelt [mailto:[EMAIL PROTECTED] Sent: 07 April 2005 13:55 To: 'OJB Users List' Cc: [EMAIL PROTECTED] Subject: OJB Listener :: Best practise Hi everybody, I need a simple Listener which methods get called after insert, update and delete. I just found Listener for Transaction stuff in the API. Any suggestions? GreetZ Nils ___ HPD Software Ltd. - Helping Business Finance Business Email terms and conditions: www.hpdsoftware.com/disclaimer - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] ___ HPD Software Ltd. - Helping Business Finance Business Email terms and conditions: www.hpdsoftware.com/disclaimer - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Connection problem
Bikram B Kapoor wrote: I am facing a serious problem with Connection in OJB. The situation this error occurs is when the site has been inactive for quite some time Use a validation query that just performs a fast/simple query to ping the database server. This can be eg SELECT 1 FROM DUAL (Oracle) or SELECT 1 (many others, I think also for MySQL). Use any SQL tool to check which validation query you can use. Put the validation query in the connection-pool settings of your OJB jdbc-connection-descriptor. For syntax read here: http://db.apache.org/ojb/docu/guides/repository.html#connection-pool-N1023A NB: this is a feature of your RDBMS server and will apply to all JDBC clients using connection pools (not OJB-specific). Regards, Martin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: OJB Listener :: Best practise
Nils Liebelt wrote: I need a simple Listener which methods get called after insert, update and delete. I just found Listener for Transaction stuff in the API. Any suggestions? If it is an option for you to modify your persistence beans, you can implement org.apache.ojb.broker.PersistenceBrokerAware and provide implementation for the following hooks: afterInsert(PersistenceBroker broker) afterUpdate(PersistenceBroker broker) afterDelete(PersistenceBroker broker) Just implement the methods you are not interested in as no-ops to cover the whole interface. When deciding which technique you want to choose, note that what I describe above will make your beans directly OJB-dependent. Regards, Martin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: OJB Listener :: Best practise
This looks like good option for me. Thanks Nils -Original Message- From: Martin Kalén [mailto:[EMAIL PROTECTED] Sent: Thursday, April 07, 2005 5:44 PM To: OJB Users List Subject: Re: OJB Listener :: Best practise Nils Liebelt wrote: I need a simple Listener which methods get called after insert, update and delete. I just found Listener for Transaction stuff in the API. Any suggestions? If it is an option for you to modify your persistence beans, you can implement org.apache.ojb.broker.PersistenceBrokerAware and provide implementation for the following hooks: afterInsert(PersistenceBroker broker) afterUpdate(PersistenceBroker broker) afterDelete(PersistenceBroker broker) Just implement the methods you are not interested in as no-ops to cover the whole interface. When deciding which technique you want to choose, note that what I describe above will make your beans directly OJB-dependent. Regards, Martin - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
mapping one object in different RDBMS
I`m trying to do mapping one object in two RDBMS and different tables. How can I create mapping and access SAME objects in different db`s on the fly ?.For example to store search results of databaseA in databaseB ? I use PB API. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
new functionality concerning setting member variables
I don't know if this is the correct place to ask, but... Is it possible to tell OJB to call setter methods on the descriptor classes instead of attempting to get the field, calling myField.setAccessible(true), and calling the myField.set() method? This will enforce the practice of creating good JavaBeans with the proper accessor methods. It will also de-couple the names of the fields with the accessor methods. At my organization, we try to keep everything consistent by conforming to a standard way of writing our Java objects. We use the notation:_fieldNamefor private member variables. I have a class with a String field called _name and getters/setters getName/setName. If I define my field descriptor as such: field-descriptor name=name / OJB throws an exception because the field name doesn't exist. Its called _name. Can I ask that OJB call the setter method instead of setting the field directly? I thought that OJB simply looked for a method get field-descriptor-name with first letter in uppercase /set field-descriptor-name with first letter in uppercase , but I guess it doesn't. This might have already been implemented and I just don't know it. I am using OJB 1.0.1. -- Bobby Lawrence MIS Application Developer Jefferson Lab (www.jlab.org) Email: [EMAIL PROTECTED] Office: (757) 269-5818 Pager: (757) 584-5818 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: new functionality concerning setting member variables
Is it possible to tell OJB to call setter methods on the descriptor classes instead of attempting to get the field, calling myField.setAccessible(true), and calling the myField.set() method? This will enforce the practice of creating good JavaBeans with the proper accessor methods. It will also de-couple the names of the fields with the accessor methods. Simply change the PersistentFieldClass setting in OJB.properties to PersistentFieldIntrospectorImplNew, this will use the property accessors. Or use PersistentFieldAutoProxyImplNew, and OJB will determine for each field whether it can use the default PersistentFieldDirectAccessImplNew (which is faster) or the (slower) PersistentFieldIntrospectorImplNew. Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: new functionality concerning setting member variables
Thanx! Armin Waibel wrote: Hi Bobby, have a look at this http://db.apache.org/ojb/docu/guides/advanced-technique.html#Change+PersistentField+Class regards, Armin Bobby Lawrence wrote: I don't know if this is the correct place to ask, but... Is it possible to tell OJB to call setter methods on the descriptor classes instead of attempting to get the field, calling myField.setAccessible(true), and calling the myField.set() method? This will enforce the practice of creating good JavaBeans with the proper accessor methods. It will also de-couple the names of the fields with the accessor methods. At my organization, we try to keep everything consistent by conforming to a standard way of writing our Java objects. We use the notation:_fieldNamefor private member variables. I have a class with a String field called _name and getters/setters getName/setName. If I define my field descriptor as such: field-descriptor name=name / OJB throws an exception because the field name doesn't exist. Its called _name. Can I ask that OJB call the setter method instead of setting the field directly? I thought that OJB simply looked for a method get field-descriptor-name with first letter in uppercase /set field-descriptor-name with first letter in uppercase , but I guess it doesn't. This might have already been implemented and I just don't know it. I am using OJB 1.0.1. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Bobby Lawrence MIS Application Developer Jefferson Lab (www.jlab.org) Email: [EMAIL PROTECTED] Office: (757) 269-5818 Pager: (757) 584-5818 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
mapping one object in different RDBMS - source
I have a problem with inserting all table data of one table to another table in other RDBMS. Following code works, but it stores not all the data, but only first object. Where I`m wrong ? Please help. import org.apache.ojb.broker.PersistenceBroker; import org.apache.ojb.broker.PersistenceBrokerException; import org.apache.ojb.broker.PersistenceBrokerFactory; import org.apache.ojb.broker.query.QueryByCriteria; import org.apache.ojb.broker.query.Criteria; import org.apache.ojb.broker.metadata.DescriptorRepository; import org.apache.ojb.broker.metadata.FieldDescriptor; import org.apache.ojb.broker.metadata.MetadataManager; import org.apache.ojb.broker.metadata.ClassDescriptor; import java.util.Iterator; public class From_MySQL_2_HSQL_DB_testing { public static void main(String args[]) { PersistenceBroker hsql_db_broker = null; PersistenceBroker mysql_db_broker = null; Object result = null; ClassDescriptor hsql_db_Domain_classDescriptor = null; ClassDescriptor mysql_db_Domain_classDescriptor = null; try { hsql_db_broker = PersistenceBrokerFactory.createPersistenceBroker(HSQL_OJB_Files, root, ); mysql_db_broker = PersistenceBrokerFactory.createPersistenceBroker(MySQL_Main_Database, root, ); hsql_db_Domain_classDescriptor = hsql_db_broker.getClassDescriptor(Domain.class); hsql_db_Domain_classDescriptor.setTableName(hsqldb_domain); mysql_db_Domain_classDescriptor = mysql_db_broker.getClassDescriptor(Domain.class); mysql_db_Domain_classDescriptor.setTableName(domain); Criteria criteria = new Criteria(); criteria.addLike(Domain, %); QueryByCriteria query = new QueryByCriteria(Domain.class, criteria); Iterator bdIterator = mysql_db_broker.getIteratorByQuery(query); while(bdIterator.hasNext()) { mysql_db_Domain_classDescriptor.setTableName(domain); result = bdIterator.next(); hsql_db_Domain_classDescriptor.setTableName(hsqldb_domain); hsql_db_broker.beginTransaction(); hsql_db_broker.store(result); hsql_db_broker.commitTransaction(); System.out.println(((Domain)result).Name); } } catch(Exception e) { e.printStackTrace(); } finally { //close HSQLDB connection hsql_db_broker.close(); //close MySQL connection mysql_db_broker.close(); } } } - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]