You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-user@db.apache.org by Ni...@arsoe-trelaze.com on 2004/04/27 11:24:46 UTC
Init error when opening db
I am sure at 80% that I make a syntaxe mistake. But I can't find where in
my configuration files. So a first question is : Does a tool existe to
verify the configuration syntaxe according to the DTD?
When I execute this lines :
protected void init()
{
// get odmg facade instance
odmg = OJB.getInstance();
db = odmg.newDatabase();
try
{
db.open(getDataSource(), getAccesRight());
}
catch (Exception ex)
{
log.error("db ouverture de la BD", ex);
}
}
I have the next exception :
java.lang.ExceptionInInitializerError
at
org.apache.ojb.broker.util.BrokerHelper.crossCheckPBKey(BrokerHelper.java:123)
at
org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl.createPersistenceBroker(PersistenceBrokerFactoryDefaultImpl.java:91)
at
org.apache.ojb.broker.PersistenceBrokerFactory.createPersistenceBroker(PersistenceBrokerFactory.java:86)
at org.apache.ojb.odmg.DatabaseImpl.open(DatabaseImpl.java:121)
at
com.arsoe.trelaze.socle.dao.odmg.ODMGDataAccessObject.init(ODMGDataAccessObject.java:125)
I use the OJB.properties and repository.dtd from the db-ojb-1.0.rc6. My
repository.xml I have the following data source declaration :
<jdbc-connection-descriptor
jcd-alias="default"
default-connection="true"
platform="MySQL"
jdbc-level="2.0"
driver="org.gjt.mm.mysql.Driver"
protocol="jdbc"
subprotocol="mysql"
dbalias="//arsodev1:3306/SuiviServices"
username="root"
password="root">
</jdbc-connection-descriptor>
The other elements are generate with xdoclet call with maven so there is
probably no errors in it ?
Nicolas
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Update Problem
Posted by Info <in...@crestax.ca>.
Hello Armin and Martin,
I am not using external seuence. I build a ID generator for it. And I am
here using primitive bigint for PK and FK without autoincrement setting.
I change a little bit and get the approch:
broker.store(department, ObjectModificationDefaultImpl.UPDATE);
Thanks for your replay,
Wallace
Martin I. Levi wrote:
>Hello Wallace,
>
>We had a similar problem here and it had to do with OJB's automatic
>increment feature.
>
>Are you using a external sequence? if that is the case check you dont
>have autoincrement set to true.
>
>Hope it helps.
>
>Greets,
>
>
>Martin Ivan Levi
>
>Universitat Politecnica de Catalunya
>Centre Tecnologic de Transferencia de Calor
>
>
>On Tue, 2004-04-27 at 06:00, Info wrote:
>
>
>>Hello,
>>
>>I am using following code to update a record:
>>
>> broker =
>>
>>
>PersistenceBrokerFactory.defaultPersistenceBroker();
>
>
>> QueryByCriteria query = new QueryByCriteria(department);
>> DepartmentDto result = (DepartmentDto)
>>broker.getObjectByQuery(query);
>> if (result != null){
>> result.setDescription(department.getDescription());
>> result.setName(department.getName());
>>
>> broker.beginTransaction();
>> broker.store(result);
>> broker.commitTransaction();
>> }
>>
>>but I get Exception:
>>
>>*org.apache.ojb.broker.PersistenceBrokerSQLException: SQL failure
>>
>>
>while
>
>
>>insert object data for class com.zousys.silique.dto.DepartmentDto, PK
>>
>>
>of
>
>
>>the given object is [ departmentId=0], object was
>>com.zousys.silique.dto.DepartmentDto@6af18d, exception message is
>>[Invalid argument value, message from server: "Duplicate entry '0' for
>>key 1"]
>>
>>*From online document, I read that OJB will check if the PK exist, if
>>yes, OJB will update the record. Anyone know why I get this error?
>>
>>Thanks a lot!
>>
>>Wallace
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>>For additional commands, e-mail: ojb-user-help@db.apache.org
>>
>>
>>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
>For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Init error when opening db
Posted by "Martin I. Levi" <ml...@labtie.mmt.upc.es>.
Hello Wallace,
We had a similar problem here and it had to do with OJB's automatic
increment feature.
Are you using a external sequence? if that is the case check you dont
have autoincrement set to true.
Hope it helps.
Greets,
Martin Ivan Levi
Universitat Politecnica de Catalunya
Centre Tecnologic de Transferencia de Calor
On Tue, 2004-04-27 at 06:00, Info wrote:
> Hello,
>
> I am using following code to update a record:
>
> broker =
PersistenceBrokerFactory.defaultPersistenceBroker();
> QueryByCriteria query = new QueryByCriteria(department);
> DepartmentDto result = (DepartmentDto)
> broker.getObjectByQuery(query);
> if (result != null){
> result.setDescription(department.getDescription());
> result.setName(department.getName());
>
> broker.beginTransaction();
> broker.store(result);
> broker.commitTransaction();
> }
>
> but I get Exception:
>
> *org.apache.ojb.broker.PersistenceBrokerSQLException: SQL failure
while
> insert object data for class com.zousys.silique.dto.DepartmentDto, PK
of
> the given object is [ departmentId=0], object was
> com.zousys.silique.dto.DepartmentDto@6af18d, exception message is
> [Invalid argument value, message from server: "Duplicate entry '0' for
> key 1"]
>
> *From online document, I read that OJB will check if the PK exist, if
> yes, OJB will update the record. Anyone know why I get this error?
>
> Thanks a lot!
>
> Wallace
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org
Re: Init error when opening db
Posted by Armin Waibel <ar...@apache.org>.
Hi,
Nicolas.CHALUMEAU@arsoe-trelaze.com wrote:
> I am sure at 80% that I make a syntaxe mistake. But I can't find where in
> my configuration files. So a first question is : Does a tool existe to
> verify the configuration syntaxe according to the DTD?
>
Most xml-tools should be able to validate an xml file against the dtd.
hmm, stack trace isn't helpful. Is this all? Normally you will find the
reason in one of the nested exception output.
If you doing something wrong in metadata mapping, enable 'DEBUG' mode for
org.apache.ojb.broker.metadata.RepositoryXmlHandler
and org.apache.ojb.broker.metadata.ConnectionDescriptorXmlHandler
If you use OJB default logging change the entries in OJB.properties.
Else it depends on the used logging framework.
regards,
Armin
> When I execute this lines :
>
> protected void init()
> {
> // get odmg facade instance
> odmg = OJB.getInstance();
>
> db = odmg.newDatabase();
> try
> {
> db.open(getDataSource(), getAccesRight());
> }
> catch (Exception ex)
> {
> log.error("db ouverture de la BD", ex);
> }
> }
>
> I have the next exception :
>
> java.lang.ExceptionInInitializerError
> at
> org.apache.ojb.broker.util.BrokerHelper.crossCheckPBKey(BrokerHelper.java:123)
> at
> org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl.createPersistenceBroker(PersistenceBrokerFactoryDefaultImpl.java:91)
> at
> org.apache.ojb.broker.PersistenceBrokerFactory.createPersistenceBroker(PersistenceBrokerFactory.java:86)
> at org.apache.ojb.odmg.DatabaseImpl.open(DatabaseImpl.java:121)
> at
> com.arsoe.trelaze.socle.dao.odmg.ODMGDataAccessObject.init(ODMGDataAccessObject.java:125)
>
> I use the OJB.properties and repository.dtd from the db-ojb-1.0.rc6. My
> repository.xml I have the following data source declaration :
>
> <jdbc-connection-descriptor
> jcd-alias="default"
> default-connection="true"
> platform="MySQL"
> jdbc-level="2.0"
> driver="org.gjt.mm.mysql.Driver"
> protocol="jdbc"
> subprotocol="mysql"
> dbalias="//arsodev1:3306/SuiviServices"
> username="root"
> password="root">
> </jdbc-connection-descriptor>
>
> The other elements are generate with xdoclet call with maven so there is
> probably no errors in it ?
>
> Nicolas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
> For additional commands, e-mail: ojb-user-help@db.apache.org
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org