RE: How to check if database is available
A simpler way could be: // depends on how you handle the PB PersistanceBroker br = PersistenceBrokerFactory.defaultPersistenceBroker(); Connection conn = br.serviceConnectionManager().getConnection(); // here you can do any checks on the conn Object (is closed, sample query ...). Roland Ribi -Original Message- From: Hiller, Frank RD-AS2 [mailto:[EMAIL PROTECTED] Sent: Friday, September 02, 2005 9:50 AM To: OJB Users List Subject: AW: How to check if database is available Hi Tom, ok, I did that. I read the parameters for the database (protocol, subprotocol, ...) from database_repository.xml. Then I try to establish a connection to the DB. If that fails the DB is not available. You don't think this could be a functionality that PB API could provide? Frank -Ursprüngliche Nachricht- Von: Thomas Dudziak [mailto:[EMAIL PROTECTED] Gesendet: Freitag, 19. August 2005 09:48 An: OJB Users List Betreff: Re: How to check if database is available On 8/19/05, Hiller, Frank RD-AS2 [EMAIL PROTECTED] wrote: how can one check via OJB whether the database is avaialable before establishing a connection to it? I think that in JDBC you'd have to try to establish a connection to it and if that fails, then likely the database is not available (for whatever reason). AFAIK there is no other generic way (though individual databases may provide other means). Since OJB builds upon JDBC, you probably got to try to establish a connection and execute the query that you've defined as the keep-alive query, and see whether this is possible. Tom - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] Confidentiality note: The information in this email and any attachment may contain confidential and proprietary information of Heidelberger Druckmaschinen AG and/or its affiliates and may be privileged or otherwise protected from disclosure. If you are not the intended recipient, you are hereby notified that any review, reliance or distribution by others or forwarding without express permission is strictly prohibited and may cause liability. In case you have received this message due to an error in transmission, we kindly ask you to notify the sender immediately and to delete this email and any attachment from your system. - 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]
Which ConnectionFactory?
Hi I user OJB in Tomcat 5.0.28, the DB-Connections are declared as JNDI-Data-Source in Tomcat (with BasicDataSourceFactory from commons-dbcp). Which ConnectionFactory should I use? When I use DBCP-ConnectionFactory it establishes for every PB a new connection, the same with PooledImpl. Any hints? Roland Ribi - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Which ConnectionFactory?
I found the solution: The configuration of BasicDataSourceFactory in for the JNDI-DataSource was wrong. I had the value minIdle =0. In this case no connection will be pooled... -Original Message- From: Ribi Roland [mailto:[EMAIL PROTECTED] Sent: Friday, August 05, 2005 2:12 PM To: 'ojb-user@db.apache.org' Subject: Which ConnectionFactory? Hi I user OJB in Tomcat 5.0.28, the DB-Connections are declared as JNDI-Data-Source in Tomcat (with BasicDataSourceFactory from commons-dbcp). Which ConnectionFactory should I use? When I use DBCP-ConnectionFactory it establishes for every PB a new connection, the same with PooledImpl. Any hints? Roland Ribi - 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: Tomcat 5.0, JNDI-DataSource and Blobs
I found a solution: Installed OJB 1.0.3 instead of 1.0.1 -Original Message- From: Ribi Roland [mailto:[EMAIL PROTECTED] Sent: Thursday, June 16, 2005 11:11 AM To: 'ojb-user@db.apache.org' Subject: Tomcat 5.0, JNDI-DataSource and Blobs Hi Since I moved the config of the connection pool from repository.xml to server.xml and get the connection via JNDI-lookup the broker throws the following Exception: ch.braunvieh.dbutils.DirectoryImageUploadVisitor - org.apache.ojb.broker.PersistenceBrokerSQLException: SQL failure while insert object data for class ch.braunvieh.ojb.argus.TFotoMitOrig, . [Oracle thin driver cannot update BLOB values with length2000. (Consider using Oracle9i as OJB platform.)] Any hints? I did'nt change the JDBC-Driver classes or any other Property... The old config in repository.xml was: jdbc-connection-descriptor jcd-alias=argus default-connection=true platform=Oracle9i jdbc-level=3.0 driver=oracle.jdbc.driver.OracleDriver protocol=jdbc subprotocol=oracle dbalias=thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=T CP)(HOST=satur n.braunvieh.ch)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=AR01.s aturn.braunvie h.ch)(SERVER=DEDICATED))) initsql=ALTER SESSION USING SCHEMA GESTHO username=x password=x ignoreAutoCommitExceptions=true useAutoCommit=0 attribute attribute-name=initsql attribute-value=ALTER SESSION SET NLS_NUMERIC_CHARACTERS='.,' / connection-pool maxActive=50 maxIdle=20 maxWait=5000 whenExhaustedAction=1 testOnBorrow=true testOnReturn=true testWhileIdle=false timeBetweenEvictionRunsMillis=360 minEvictableIdleTimeMillis=180 numTestsPerEvictionRun=20 validationQuery=SELECT PA_ANI.nGetAniID('US 184087.2') FROM DUAL / sequence-manager className=org.apache.ojb.broker.util.sequence.SequenceManager NextValImpl / /jdbc-connection-descriptor And now it is: jdbc-connection-descriptor jcd-alias=argus jndi-datasource-name=java:/comp/env/jdbc/argus default-connection=true platform=Oracle9i jdbc-level=3.0 ignoreAutoCommitExceptions=true useAutoCommit=0 driver=oracle.jdbc.driver.OracleDriver attribute attribute-name=initsql attribute-value=ALTER SESSION SET NLS_NUMERIC_CHARACTERS='.,' / sequence-manager className=org.apache.ojb.broker.util.sequence.SequenceManager NextValImpl / /jdbc-connection-descriptor The Connection-Pool is defined as follows in the server.xml: Resource name=argus auth=Container type=javax.sql.DataSource/ ResourceParams name=argus parameter namefactory/name valueorg.apache.commons.dbcp.BasicDataSourceFactory/value /parameter parameter namedriverClassName/name valueoracle.jdbc.driver.OracleDriver/value /parameter parameter nameurl/name valuejdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=( PROTOCOL=TCP)( HOST=saturn.braunvieh.ch)(PORT=1521)))(CONNECT_DATA=(SERVICE_N AME=AR01.satur n.braunvieh.ch)(SERVER=DEDICATED)))/value /parameter parameter nameusername/name valuex/value /parameter parameter namepassword/name valuex/value /parameter parameter nameinitialSize/name value1/value /parameter parameter namemaxActive/name value5/value /parameter parameter namemaxIdle/name value2/value /parameter parameter nameminIdle/name value1/value /parameter parameter namemaxWait/name value-1/value /parameter parameter namevalidationQuery/name valueSELECT PA_ANI.nGetAniID('US 184087.2') FROM DUAL/value /parameter parameter nametestOnBorrow/name valuetrue/value /parameter parameter nametestOnReturn/name valuetrue/value /parameter parameter nametestWhileIdle/name valuefalse/value /parameter parameter nametimeBetweenEvictionRunsMillis/name value360/value /parameter parameter namenumTestsPerEvictionRun/name value5/value /parameter parameter nameminEvictableIdleTimeMillis/name value180/value /parameter parameter namewhenExhaustedAction/name value2/value /parameter /ResourceParams - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED
RE: Reconnecting to the database
I don't konw if this helps in managed environments. We use ConnectionFactoryPooledImpl and it works with the following connection-pool settings: connection-pool maxActive=100 maxIdle=20 maxWait=5000 whenExhaustedAction=2 testOnBorrow=true testOnReturn=true testWhileIdle=false timeBetweenEvictionRunsMillis=360 minEvictableIdleTimeMillis=180 numTestsPerEvictionRun=20 validationQuery=SELECT 1 FROM DUAL/ OJB closes the connections and reopens new connections if there is any error with the connection. Roland -Original Message- From: Joe Germuska [mailto:[EMAIL PROTECTED] Sent: Thursday, February 03, 2005 4:39 PM To: OJB Users List Subject: Re: Reconnecting to the database Hear, hear! We are finding this quite annoying as well. I thought because we were using the org.apache.ojb.broker.accesslayer.ConnectionFactoryManagedImpl class, that management would defer to JBoss, which does recover from a Database server reboot. However, it turns out that it does not. Any solutions would be greatly appreciated. Joe At 9:50 AM +1100 2/3/05, Joe Latty wrote: We are having a problem when our database server is rebooted we have to restart all of our apps that use OJB (an inconvenience). Is there a way to set up the repository to try for a new connection if it can no longer connect? Do I manually have to catch the exception, identify it and try and re-establish connection to the db? Thanks Joe -- Joe Germuska [EMAIL PROTECTED] http://blog.germuska.com Narrow minds are weapons made for mass destruction -The Ex - 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: starting ojb
Did you set the following in one jdbc-connection-descriptor: default-connection=true example: jdbc-connection-descriptor jcd-alias=argus default-connection=true platform=Oracle9i Roland Ribi -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Friday, December 10, 2004 10:26 AM To: [EMAIL PROTECTED] Subject: starting ojb I have always the same problem. I have put the needed xml files in the folder where my application is. but there is the same mistake. [JDO] DEBUG: OjbStoreConnector.begin: connectionReadyForRelease=false org.apache.ojb.broker.PBFactoryException: There was no default-PBKey specified at org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl.de faultPersistenceBroker(Unknown Source) at org.apache.ojb.broker.PersistenceBrokerFactory.defaultPersiste nceBroker(Unknown Source) at org.apache.ojb.jdori.sql.OjbStoreConnector.begin(Unknown Source) at com.sun.jdori.common.TransactionImpl.beginInternal(Unknown Source) at com.sun.jdori.common.TransactionImpl.begin(Unknown Source) at org.myProject.appli.Demo.storing(Demo.java:97) at org.myProject.appli.Demo.main(Demo.java:110) Exception in thread main which information do you need to get an idea where the mistake is.? regards Michael - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Best Practise for OJB
Hi, Thats ok, but be very careful with sequence managers - i know most of them are NOT happy with other apps doing inserts! see: http://db.apache.org/ojb/docu/guides/sequencemanager.html yes I have not Other solution I can not convert Webapp 2 to use same Ojb cache or OJB. I also work with an enviroment where different apps uses the same database. With native oracle sequences it isn't a problem because this are sequences, which does'nt give the same value twice also on different sessions or applications. I use the following sequence manager: sequence-manager className=org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl / and I use native oracle sequences in the mapping like thies: field-descriptor name=texpId column=TEXP_ID jdbc-type=BIGINT conversion=ch.braunvieh.ojb.db.Long2LongFieldConversion sequence-name=GESTHO.S_T_TIEREXPORT autoincrement=true primarykey=true / My Problem when Webapp 2 (Update or Insert) in the Data Base the result is no 't visible for the Webapp 1 what is best using for performance A possible way would be to write a cache manager which becomes informed of updates/inserts of other application by triggers on each table. In Oracle you could use the PL/SQL-package DBMS_ALERT for the information exchange of db and ojb, because there are functions/procedures which only send messages on commit. If you use only OJB to access the db you could write a cachemanager which does the same on OJB level instead of DB level, one app informs the other on updates/inserts. At the moment I use: ObjectCacheClass=org.apache.ojb.broker.cache.ObjectCacheEmptyImpl which means NO CACHE ...but in future I will need to use the trigger system to manage the cache. regards Roland - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ojb 1.0.1 does'nt uses connection-pool /?
Hi, Thanks for this hint! Roland Ribi -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 16, 2004 10:55 AM To: OJB Users List Subject: Re: ojb 1.0.1 does'nt uses connection-pool /? Hi Roland, you have differ between PersistenceBroker pooling (the PersistenceBrokerFactory pools PB insances) and Connection pooling (dependent on the used ConnectionFactory implementation connection pooling could be used). The first one can be configured in OJB.properties file, the second one in the repository file. regards, Armin Ribi Roland wrote: Hi, Is it correct that ojb 1.0.1 does'nt uses the connection-pool / settings from repository.xml and uses the defaults in OJB.properties instead? I had the following settings but it did'nt used it: connection-pool maxActive=500 maxIdle=100 maxWait=-1 whenExhaustedAction=2 testOnBorrow=true testOnReturn=true testWhileIdle=true timeBetweenEvictionRunsMillis=5000 minEvictableIdleTimeMillis=6 numTestsPerEvictionRun=5 validationQuery=SELECT 1 FROM DUAL/ I tried many settings and I had always the same Exceptions at a specific amount of request on my tomcat application. Now I tried to set this settings in the OJB.properties and it works ... Is it a bug or a feature? :) Roland Ribi - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
ojb 1.0.1 does'nt uses connection-pool /?
Hi, Is it correct that ojb 1.0.1 does'nt uses the connection-pool / settings from repository.xml and uses the defaults in OJB.properties instead? I had the following settings but it did'nt used it: connection-pool maxActive=500 maxIdle=100 maxWait=-1 whenExhaustedAction=2 testOnBorrow=true testOnReturn=true testWhileIdle=true timeBetweenEvictionRunsMillis=5000 minEvictableIdleTimeMillis=6 numTestsPerEvictionRun=5 validationQuery=SELECT 1 FROM DUAL/ I tried many settings and I had always the same Exceptions at a specific amount of request on my tomcat application. Now I tried to set this settings in the OJB.properties and it works ... Is it a bug or a feature? :) Roland Ribi - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: validation query for connection failed
Hi, I also had problems with the broker and now I'm realised, that only if I define the connection Pool in both files where it is possible (OJB.properties AND reposistory.xml), it works like we want. I tried many settings and tested it with JMeter and produced havy laod on the web application. The connection pool didn't grow over 21 connections to the db. Only with setting of maxActive=100 and maxIdle=20 in repository.xml and OJB.properties it growed over 21 connection on havy load. I don't know why but now it works fine now. I searched in the source of OJB and found the default settings in org.apache.ojb.broker.util.pooling.PoolConfiguration. Try to make the settings in both files. Roland Ribi -Original Message- From: Thomas Franke [mailto:[EMAIL PROTECTED] Sent: Monday, November 15, 2004 5:26 PM To: OJB Users List Subject: Re: validation query for connection failed Ribi Roland wrote: Thanks for your help, Roland. http://www.websina.com/bugzero/kb/oracle-connection.html This is not our problem, because we almost always get a connection. The problem only occurs sometimes. But to often. An other problem could be that some Broker stay open after use. I had this behavior in my tomcat-application. After I checked the code where a PersistenceBroker is used and implemented the call of the close method correctly at the end of any request (also if it throws an exception!), it works fine. We found one method, where the broker wasn't closed. Now all the brokers are definitely being closed in a finally block but our problem is still there. regards Thomas -- Mit freundlichen Grüßen Thomas Franke Geschäftsführer softEnergy GmbH The energy for a better world softEnergy GmbH Platz der Freundschaft 1 18059 Rostock fon: +49 381 40 587 535 fax: +49 381 40 587 555 mobil: +49 1715222015 http://www.softenergy.de mail: [EMAIL PROTECTED] - 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: validation query for connection failed
Hi Thomas I don't know, but perhaps this helps: http://www.websina.com/bugzero/kb/oracle-connection.html This was one problem in our installation. An other problem could be that some Broker stay open after use. I had this behavior in my tomcat-application. After I checked the code where a PersistenceBroker is used and implemented the call of the close method correctly at the end of any request (also if it throws an exception!), it works fine. regards Roland Ribi -Original Message- From: Thomas Franke [mailto:[EMAIL PROTECTED] Sent: Thursday, November 11, 2004 11:00 AM To: OJB Users List Subject: Re: validation query for connection failed Armin Waibel wrote: which version of OJB do you use? We still use db-ojb-1.0.rc6 but we are going to use the current realease. Normally ConnectionFactoryPooledImpl tries 100 times to lookup a valid connection from the DB, so you should get the warning several times before the pool break. Could you post the whole stack trace? Here it is: -begin [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] WARN: Validation query for connection failed, discard connection. Query was select count(*) from datenklasse, Message was E/A-Exception: Socket closed [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] WARN: Validation query for connection failed, discard connection. Query was select count(*) from datenklasse, Message was E/A-Exception: Socket closed [org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl] WARN: Validation query for connection failed, discard connection. Query was select count(*) from datenklasse, Message was E/A-Exception: Socket closed [org.apache.ojb.broker.accesslayer.JdbcAccessImpl] ERROR: PersistenceBrokerException during the execution of the query: Used ConnectionManager instance could not obtain a connection Used ConnectionManager instance could not obtain a connection org.apache.ojb.broker.PersistenceBrokerException: Used ConnectionManager instance could not obtain a connection at org.apache.ojb.broker.accesslayer.StatementManager.getPreparedStatement(Unkn own Source) at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeQuery(Unknown Source) at org.apache.ojb.broker.accesslayer.RsQueryObject.performQuery(Unknown Source) at org.apache.ojb.broker.accesslayer.RsIterator.init(Unknown Source) at org.apache.ojb.broker.core.RsIteratorFactoryImpl.createRsIterator(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getRsIteratorFromQuery(Unkn own Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorFromQuery(Unknow n Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Unknown Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unkn own Source) at org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery(Unkn own Source) at de.mhr.wis.DBAdapter.ojbAdapter.Utils.getWea(Utils.java:627) at de.mhr.wis.DBAdapter.ojbAdapter.management.OjbLogbuchAdapter.importStatusdat en(OjbLogbuchAdapter.java:392) at de.mhr.wis.businessLayer.logic.management.LogBook.importStatusdaten(LogBook. java:879) at de.mhr.wis.businessLayer.facades.rawdata.RawDataFacade.importStatusdaten(Raw DataFacade.java:50) at de.mhr.wis.communicationlayer.communicationmanager.importers.MitaImporter.im portStatus(MitaImporter.java:723) at de.mhr.wis.communicationlayer.communicationmanager.importers.MitaImporter.im portSingleRawFile(MitaImporter.java:358) at de.mhr.wis.communicationlayer.communicationmanager.importers.MitaImporter.im portRawFile(MitaImporter.java:249) at de.mhr.wis.communicationlayer.communicationmanager.RawFileManager.run(RawFil eManager.java:221) Caused by: org.apache.ojb.broker.accesslayer.LookupException: Could not borrow connection from pool - org.apache.ojb.broker.metadata.JdbcConnectionDescriptor: [EMAIL PROTECTED] jcd-alias=default default-connection=true dbms=Oracle9i jdbc-level=2.0 driver=oracle.jdbc.driver.OracleDriver protocol=jdbc sub-protocol=oracle db-alias=thin:@(description=(address=(host=xxx.xx.x.xxx)(protocol=tcp)(port= 1521))(connect_data=(sid=xxx)(server=dedicated))) user=xx password=* eager-release=false ConnectionPoolDescriptor={whenExhaustedAction=1, validationQuery=select count(*) from datenklasse, maxIdle=10, maxActive=41, maxWait=2, removeAbandoned=false, numTestsPerEvictionRun=10, testWhileIdle=true, minEvictableIdleTimeMillis=-1, testOnReturn=false, logAbandoned=false, removeAbandonedTimeout=300, timeBetweenEvictionRunsMillis=-1, testOnBorrow=true} batchMode=false useAutoCommit=AUTO_COMMIT_SET_TRUE_AND_TEMPORARY_FALSE ignoreAutoCommitExceptions=false [EMAIL PROTECTED] sequenceManagerClass=class
Close all DB-Connections at servlet shutdown
Hi We use OJB in servlets. Now I discovered that the Connections to the oracle DB arn't closed correctly at servlet shutdown. They stay open and after a number of restarts of the servlets I can't connect to oracle because there are to many open connections. Which method does I need to call to close all the open connections to any DB? I would like to implement this in the destroy-mehtod of the servlet. Roland Ribi - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Close all DB-Connections at servlet shutdown
It works with the call of releaseAllResources(). Thanks. -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Friday, July 02, 2004 12:11 PM To: OJB Users List Subject: Re: Close all DB-Connections at servlet shutdown Hi Roland, Ribi Roland wrote: Hi We use OJB in servlets. Now I discovered that the Connections to the oracle DB arn't closed correctly at servlet shutdown. They stay open and after a number of restarts of the servlets I can't connect to oracle because there are to many open connections. Which method does I need to call to close all the open connections to any DB? I would like to implement this in the destroy-mehtod of the servlet. Try ConnectionFactoryFactory.getInstance().createConnectionFactory ().releaseAllResources() Not really smart, but give it a try. Till 1.1 we will get rid of all singletons, so this section will be easier to control in future. regards, Armin Roland Ribi - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ClassCastException when storing a Date
Use jdbc-type=TIMESTAMP in the repository.xml for DATE-Fields and java.util.Date will work. If you use java.sql.Date you can only handle days and not the hours, minuts and seconds. Roland Ribi -Original Message- From: Marco José [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 26, 2004 5:14 PM To: [EMAIL PROTECTED] Subject: ClassCastException when storing a Date Hi. I'm working under Oracle9 and have a problem when I try to insert a date. I have already some data in the DB which was inserted with a SQL Client. When I query these data with OJB, the dates are listed in the following pattern: -MM-dd. Now when I insert a date into an object (java.util.Date) it uses the pattern: EEE, MMM dd HH:mm:ss Z and therefore the PersistenceBroker throws a ClassCastException when trying to store this object. Can anybody tell me how to resolve this problem? Do I have to edit the repository.xml file? Thank you in advance, Marco José --- This message may contain confidential information or privileged material, and is intended only for the individual(s) named. If you are not a named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. E-mail transmission cannot be guaranteed to be secure or error-free as information could be intercepted, corrupted, lost, destroyed, arrive late or incomplete, or contain viruses. The sender therefore does not accept liability for any errors or omissions in the contents of this message which arise as a result of e-mail transmission. If verification is required please request a hard-copy version. Critical Software. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: ALTER SESSION Statements
The javadoc on the ojb website isn't complete. I didn't find ConnectionFactoryAbstractImpl there. Can anybody update this? Roland Ribi -Original Message- From: Armin Waibel [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 18, 2004 12:30 PM To: OJB Users List Subject: Re: ALTER SESSION Statements Hi Roland, Ribi Roland wrote: Is there a way in ojb to put some initial statements, which are called after logon to the database for each DB-connection? Have a look in ConnectionFactory implementation classes. ConnectionFactory is responsible for creation, pooling, close of connections. All implementations are derived from ConnectionFactoryAbstractImpl. There are two protected methods: newConnectionFromDriverManager newConnectionFromDataSource these methods were called to create new connections. So it should be no problem to derived a ConnectionFactory implementation and override these methods to do the initial stuff. regards, Armin Roland Ribi - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Maximum open cursors exceeded
This is'nt the problem of the query, this is because the close() Method of a java.sql.Statement-Object is'nt called after the query. Oracle needs to close all open cursers after the query is finished. This occurs after too many SQL-Calls to the database without closing the cursor. You can also create this behavior whith stored procedures in Oracle. Perhaps ojb does'nt closes the Statements in this QueryBySQL ? Roland Ribi -Original Message- From: Mindy Pereira [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 05, 2004 5:02 PM To: OJB Users List Subject: Maximum open cursors exceeded I'm getting a collection beans using a QueryBySQL. Previously, it worked with no problems, however, when I added another filter to the data set (where X = Y and Z = 2 and W = 3), I got the following error: [org.apache.ojb.broker.accesslayer.StatementsForClassImpl] ERROR: ORA-01000: max imum open cursors exceeded Any help would be appreciated. Mindy - 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: Maximum open cursors exceeded
I'm not a OJB Guru, perhaps anyone else here can help? It could be a bug in OJB. But I don't know the Ojb very well. Roland Ribi -Original Message- From: Mindy Pereira [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 05, 2004 5:10 PM To: OJB Users List Subject: RE: Maximum open cursors exceeded If that's the problem, how do I force OJB to close the statement? -Original Message- From: Ribi Roland [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 05, 2004 11:08 AM To: 'OJB Users List' Subject: RE: Maximum open cursors exceeded This is'nt the problem of the query, this is because the close() Method of a java.sql.Statement-Object is'nt called after the query. Oracle needs to close all open cursers after the query is finished. This occurs after too many SQL-Calls to the database without closing the cursor. You can also create this behavior whith stored procedures in Oracle. Perhaps ojb does'nt closes the Statements in this QueryBySQL ? Roland Ribi -Original Message- From: Mindy Pereira [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 05, 2004 5:02 PM To: OJB Users List Subject: Maximum open cursors exceeded I'm getting a collection beans using a QueryBySQL. Previously, it worked with no problems, however, when I added another filter to the data set (where X = Y and Z = 2 and W = 3), I got the following error: [org.apache.ojb.broker.accesslayer.StatementsForClassImpl] ERROR: ORA-01000: max imum open cursors exceeded Any help would be appreciated. Mindy - 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] - 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]
Using OJB RC6 in a Servlet Container
Hi With RC5 I had'nt any errors on deploying ojb in a Tomcat 4.1.29 Instance. Now I tryed to use RC6 an had always the following error. Can anyone tell me, what this means? I tryed to add or remove some jar-Files but I did'nt find out where the problem begins. I tried olso Tomcat 5.0.19 and had the same error. Also the ojb-servlet.war had the same error. Any hint? INFO: Error installing java.lang.IllegalArgumentException: javacc,ant,commons-collections,log4j,junit-Extension-Name at java.util.jar.Attributes$Name.init(Attributes.java:434) at java.util.jar.Attributes.getValue(Attributes.java:97) at org.apache.catalina.util.ManifestResource.getRequiredExtensions(ManifestReso urce.java:243) at org.apache.catalina.util.ManifestResource.processManifest(ManifestResource.j ava:212) at org.apache.catalina.util.ManifestResource.init(ManifestResource.java:96) at org.apache.catalina.util.ExtensionValidator.validateApplication(ExtensionVal idator.java:250) at org.apache.catalina.core.StandardContext.start(StandardContext.java:4133) at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:8 66) at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:850) at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:638) at org.apache.catalina.core.StandardHostDeployer.install(StandardHostDeployer.j ava:320) at org.apache.catalina.core.StandardHost.install(StandardHost.java:875) at org.apache.catalina.manager.ManagerServlet.deploy(ManagerServlet.java:927) at org.apache.catalina.manager.HTMLManagerServlet.deployInternal(HTMLManagerSer vlet.java:320) at org.apache.catalina.manager.HTMLManagerServlet.doPost(HTMLManagerServlet.jav a:300) at javax.servlet.http.HttpServlet.service(HttpServlet.java:763) at javax.servlet.http.HttpServlet.service(HttpServlet.java:856) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:284) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:204) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja va:257) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex t.java:151) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567) at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContext Valve.java:245) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja va:199) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex t.java:151) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase .java:587) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex t.java:149) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:184 ) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex t.java:151) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164 ) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex t.java:149) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java :156) at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContex t.java:151) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:567) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972) at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:833) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConne ction(Http11Protocol.java:732) at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:619) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.jav a:688) at java.lang.Thread.run(Thread.java:534) 28.04.2004 08:27:56 org.apache.catalina.core.StandardHostDeployer install INFO: Installing web application at context path /ojb-servlet from URL file:C:/Programme/Apache Software Foundation/Tomcat 5.0/webapps/ojb-servlet Roland Ribi - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
reverse-Tool with Oracle 8.1.7
Hi I would like to use the reverse-tool to genereate the repository.xml and the java code. But the reverse-tool takes always DECIMAL (JDBC-Type) and Long (Java-Type) for any Number column in Oracle. How can I override this so that a NUMBER(4) Column is mapped from BIGINT (JDBC-Type) to Long (Java) and a Column with NUMBER(6,2) is mapped from DOUBLE (JDBC-Type) to Double (Java)? Does I need to do this manually or can I declare the mapping in the OJB.properties or does I need to customize a class of OJB and if yes which one or how? With the default behavior I get ClasCastExceptions when I try to get any row from the database. Roland Ribi - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: reverse-Tool with Oracle 8.1.7
Hi I found the specific class and added the follwing code to the class org.apache.ojb.tools.mapping.reversedb.DBSchema in the read-method before the call of this.addColumn(...): if(iDataType == java.sql.Types.DECIMAL){ if(iDecimalDigits0) { iDataType = java.sql.Types.DOUBLE; } else { iDataType = java.sql.Types.BIGINT; } } It's a simple workaround, perhaps it helps to develope a better revers-db-Tool in future... Roland Ribi -Original Message- From: Ribi Roland [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 28, 2004 2:19 PM To: '[EMAIL PROTECTED]' Subject: reverse-Tool with Oracle 8.1.7 Hi I would like to use the reverse-tool to genereate the repository.xml and the java code. But the reverse-tool takes always DECIMAL (JDBC-Type) and Long (Java-Type) for any Number column in Oracle. How can I override this so that a NUMBER(4) Column is mapped from BIGINT (JDBC-Type) to Long (Java) and a Column with NUMBER(6,2) is mapped from DOUBLE (JDBC-Type) to Double (Java)? Does I need to do this manually or can I declare the mapping in the OJB.properties or does I need to customize a class of OJB and if yes which one or how? With the default behavior I get ClasCastExceptions when I try to get any row from the database. Roland Ribi - 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: reverse-Tool with Oracle 8.1.7
I fogot one line: int iDecimalDigits = rs.getInt(DECIMAL_DIGITS); this comes before my other code: if(iDataType == java.sql.Types.DECIMAL){ if(iDecimalDigits0) { iDataType = java.sql.Types.DOUBLE; } else { iDataType = java.sql.Types.BIGINT; } } Roland Ribi -Original Message- From: Ribi Roland [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 28, 2004 4:57 PM To: 'OJB Users List' Subject: RE: reverse-Tool with Oracle 8.1.7 Hi I found the specific class and added the follwing code to the class org.apache.ojb.tools.mapping.reversedb.DBSchema in the read-method before the call of this.addColumn(...): if(iDataType == java.sql.Types.DECIMAL){ if(iDecimalDigits0) { iDataType = java.sql.Types.DOUBLE; } else { iDataType = java.sql.Types.BIGINT; } } It's a simple workaround, perhaps it helps to develope a better revers-db-Tool in future... Roland Ribi -Original Message- From: Ribi Roland [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 28, 2004 2:19 PM To: '[EMAIL PROTECTED]' Subject: reverse-Tool with Oracle 8.1.7 Hi I would like to use the reverse-tool to genereate the repository.xml and the java code. But the reverse-tool takes always DECIMAL (JDBC-Type) and Long (Java-Type) for any Number column in Oracle. How can I override this so that a NUMBER(4) Column is mapped from BIGINT (JDBC-Type) to Long (Java) and a Column with NUMBER(6,2) is mapped from DOUBLE (JDBC-Type) to Double (Java)? Does I need to do this manually or can I declare the mapping in the OJB.properties or does I need to customize a class of OJB and if yes which one or how? With the default behavior I get ClasCastExceptions when I try to get any row from the database. Roland Ribi - 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] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: mssql: sqlexception
Hi I had also a problem with java.util.Date on a Oracle DB. I had to change the types in my classes to java.sql.Date and it works fine now. An other way could be a conversion-class for java.util.Date (like Integer2IntegerFieldConversion) which creates a java.sql.Date from java.util.Date. Let me now if it solves your problem. Roland Ribi -Original Message- From: Pedro Salgado [mailto:[EMAIL PROTECTED] Sent: Thursday, January 01, 1970 2:47 AM To: OJB Users List Subject: mssql: sqlexception For several reasons, I have been using a OJB/MySQL development platform and everything was going ok. The problem was when I chose to test the same application with a OJB/MSSQL platform. Apart of some minor changes, I made it all work except for a class (the source and OJB description is below) that has a TIMESTAMP/DATETIME mapping and that also could be NULL (also tried with NOT NULL = nullable=false and didn't work either). I tried Google and it seems a MSSQL JDBC driver bug (don't know if it could be a bug in OJB) but I wonder if anyone has came across with this problem and solved this or found a way around (please don't tell me I have to store the day-month-year on 3 database fields for each date :( or change it to a char/varchar field). Below is the error (log file) the DAO, OJB descriptor and SQL for the class in question. All help/ideas are welcome, Pedro Salgado --- LOG FILE 12:46:34,503 - DEBUG org.apache.ojb.broker.accesslayer.StatementManager - closeResources was called 12:46:34,503 - DEBUG org.apache.ojb.broker.accesslayer.JdbcAccessImpl - executeInsert : [EMAIL PROTECTED] 12:46:34,503 - DEBUG org.apache.ojb.broker.accesslayer.sql.SqlGeneratorDefaultImpl - SQL:INSERT INTO REVISIONS (id,document,title,edition,date_implementation,date_issued,dat e_approval,dat e_approval_qa,date_authorization,date_cancelled,date_deadline, originator,app rover,approver_qa,authorizer,canceller,obs,state,sys_extension) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) 12:46:34,519 - ERROR org.apache.ojb.broker.accesslayer.JdbcAccessImpl - SQLException during the execution of the insert (for a pkg.pkg.dao.Revision): [Microsoft][SQLServer 2000 Driver for JDBC]Unable to determine the type of the specified object. java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Unable to determine the type of the specified object. at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source) at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source) at com.microsoft.jdbc.base.BasePreparedStatement.setObject(Unknown Source) at org.apache.ojb.broker.platforms.PlatformDefaultImpl.setObjectF orStatement(Un known Source) at org.apache.ojb.broker.accesslayer.StatementManager.bindInsert(Unknown Source) at org.apache.ojb.broker.accesslayer.JdbcAccessImpl.executeInsert(Unknown Source) at org.apache.ojb.broker.core.PersistenceBrokerImpl.storeToDb(Unknown Source) --- Java class (Date = java.util.Date) private int id = 0; private int document = 0; private String Title = null; private String Edition = null; private Date dateImplementation = null; private Date dateIssued = null; private Date dateApproval = null; private Date dateApprovalQA = null; private Date dateAuthorization = null; private Date dateCancelled = null; private Date dateDeadline = null; private int originator = 0; private int approver = 0; private int approverQA = 0; private int authorizer = 0; private int canceller = 0; private String comment = null; private int State = 0; private String fileExtension = null; --- MSSQL SQL IF EXISTS (SELECT 1 FROM sysobjects WHERE type ='RI' AND name='REVISIONS_FK_1') ALTER TABLE REVISIONS DROP CONSTRAINT REVISIONS_FK_1; IF EXISTS (SELECT 1 FROM sysobjects WHERE type = 'U' AND name = 'REVISIONS') BEGIN DECLARE @reftable_7 nvarchar(60), @constraintname_7 nvarchar(60) DECLARE refcursor CURSOR FOR select reftables.name tablename, cons.name constraintname from sysobjects tables, sysobjects reftables, sysobjects cons, sysreferences ref where tables.id = ref.rkeyid and cons.id = ref.constid and reftables.id = ref.fkeyid and tables.name = 'REVISIONS' OPEN refcursor FETCH NEXT from refcursor into @reftable_7, @constraintname_7 while @@FETCH_STATUS = 0 BEGIN exec ('alter table '[EMAIL PROTECTED]' drop constraint '[EMAIL PROTECTED]) FETCH NEXT from refcursor into @reftable_7, @constraintname_7 END CLOSE refcursor DEALLOCATE refcursor DROP TABLE REVISIONS END CREATE TABLE REVISIONS ( id INT NOT NULL, document INT NOT NULL,