Armin,
I tried this but it did not work.
As I wrote I tried to use the MetadataManager:
// ==== test persistence
// get MetadataManager instance
MetadataManager mm = MetadataManager.getInstance();
// read connection metadata from repository file
ConnectionRepository cr =
mm.readConnectionRepository("repository_database.xml");
// merge new connection metadata with existing one
mm.mergeConnectionRepository(cr);
// read the additional repository file
DescriptorRepository dr =
mm.readDescriptorRepository("repository_user.xml");
// merge the new class-descriptor with existing object metadata
mm.mergeDescriptorRepository(dr);
// open database
Implementation odmg = OJB.getInstance();
Database db = odmg.newDatabase();
db.open("default", Database.OPEN_READ_WRITE);
// save data
Transaction tx = odmg.newTransaction();
tx.begin();
tx.lock(el, Transaction.WRITE);
tx.commit();
// close database
db.close();
// ==== end test persistence
After my first test I've got an exception "unexpected sign at the end of
file" or something like that. After deleting all jdbc-connection-descriptors
(not my mysql-descriptor) the exception disappeared. Then I had a problem
with a class that the MetadataManager could not found. I fixed that by
placing the commons-dbcp-1.1.jar at the classpath. After this everything
worked fine and I could store my first object in the database! OJB is really
great stuff!!! :-)))
regards,
Marko
> Marko Huebler wrote:
>
> > Armin,
> >
> > I will test it again and post you the stack trace. If it still not works
> I
> > will also try to use the MetadataMangager and the ConnectionRepository
> (or
> > something like that) to read the repository by myself (then I have the
> > possibility to specify the path). Maybe this works...
> >
>
> >>>I placed them
> >>>in the same directory as the main-class of my test application and the
> >>>OJB.properties-file are.
>
> You should place the OJB files in the working directory of your JVM or
> in a directory contained in the classpath of your application.
>
> Armin
>
>
>
> > Marko
> >
> >
> >>
> >>Marko Huebler wrote:
> >>
> >>>Hi Armin,
> >>>
> >>>I already tested this. The error was the same ("... does not match in
> >>>metadata configuration"). Maybe the repository can't be read.
> >>
> >>hmm, if this is the problem you should see an appropriate error message
> >>in the nested exception stack trace.
> >>
> >>Armin
> >>
> >>
> >>
> >>>I placed them
> >>>in the same directory as the main-class of my test application and the
> >>>OJB.properties-file are.
> >>>
> >>>regards,
> >>>Marko
> >>>
> >>>
> >>>
> >>>
> >>>>Hi Marko,
> >>>>
> >>>>
> >>>>> //db.open("default#root#root", Database.OPEN_READ_WRITE);
> >>>>
> >>>>should be the right way to open the Database.
> >>>>If this doesn't work please post the whole stack
> >>>>
> >>>>regards,
> >>>>Armin
> >>>>
> >>>>
> >>>>
> >>>>Marko Huebler wrote:
> >>>>
> >>>>
> >>>>
> >>>>>Hi,
> >>>>>
> >>>>>I'm currently testing out the ODMG implementaton of OJB. Unfortunatly
> I
> >>>>>can't get it working:
> >>>>>
> >>>>> // open database
> >>>>> Implementation odmg = OJB.getInstance();
> >>>>> Database db = odmg.newDatabase();
> >>>>> //db.open("default#root#root", Database.OPEN_READ_WRITE);
> >>>>> db.open("default", Database.OPEN_READ_WRITE);
> >>>>>
> >>>>>
> >>>>> // close database
> >>>>> db.close();
> >>>>>
> >>>>>"db.open" causes following error:
> >>>>>
> >>>>>[org.apache.ojb.odmg.DatabaseImpl] ERROR: Open database failed:
> Borrow
> >>>>>broker from pool failed, using PBKey org.apache.ojb.broker.PBKey:
> >>>>>jcdAlias=default, user=null, password=null
> >>>>>Borrow broker from pool failed, using PBKey
> >>
> >>org.apache.ojb.broker.PBKey:
> >>
> >>>>>jcdAlias=default, user=null, password=null
> >>>>>org.apache.ojb.broker.PBFactoryException: Borrow broker from pool
> >>>>
> >>>>failed,
> >>>>
> >>>>
> >>>>>using PBKey org.apache.ojb.broker.PBKey: jcdAlias=default, user=null,
> >>>>>password=null
> >>>>> at
> >>>>>
> >>>>
> >
>
org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl.createPersistenceBroker(Unknown
> >
> >>>>>Source)
> >>>>> at
> >>>>>
> >>>>
> >
>
org.apache.ojb.broker.PersistenceBrokerFactory.createPersistenceBroker(Unknown
> >
> >>>>>Source)
> >>>>> at org.apache.ojb.odmg.DatabaseImpl.open(Unknown Source)
> >>>>> at MainTest.main(MainTest.java:57)
> >>>>>Caused by: org.apache.ojb.broker.PBFactoryException: Given PBKey
> >>>>>org.apache.ojb.broker.PBKey: jcdAlias=default, user=null,
> password=null
> >>>>
> >>>>does
> >>>>
> >>>>
> >>>>>not match in metadata configuration
> >>>>> at
> >>>>>
> >>>>
> >
>
org.apache.ojb.broker.core.PersistenceBrokerFactoryBaseImpl.createNewBrokerInstance(Unknown
> >
> >>>>>Source)
> >>>>> at
> >>>>>
> >>>>
> >
>
org.apache.ojb.broker.core.PersistenceBrokerFactoryDefaultImpl$PBKeyedPoolableObjectFactory.makeObject(Unknown
> >
> >>>>>Source)
> >>>>> at
> >>>>>
> >>>>
> >
>
org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:792)
> >
> >>>>> ... 4 more
> >>>>>org.odmg.DatabaseNotFoundException: OJB can't open database default
> >>>>>Borrow broker from pool failed, using PBKey
> >>
> >>org.apache.ojb.broker.PBKey:
> >>
> >>>>>jcdAlias=default, user=null, password=null
> >>>>> at org.apache.ojb.odmg.DatabaseImpl.open(Unknown Source)
> >>>>> at MainTest.main(MainTest.java:57)
> >>>>>Exception in thread "main"
> >>>>>
> >>>>>Does anyone know where the problem could be? I'm using a MySQL
> >>
> >>database.
> >>
> >>>>>This is my connection descriptor:
> >>>>>
> >>>>> <!-- this connection was used as the default one within OJB -->
> >>>>> <jdbc-connection-descriptor
> >>>>> jcd-alias="default"
> >>>>> default-connection="true"
> >>>>> platform="MySQL"
> >>>>> jdbc-level="3.0"
> >>>>> driver="com.mysql.jdbc.Driver"
> >>>>> protocol="jdbc"
> >>>>> subprotocol="mysql"
> >>>>> dbalias="//localhost:3306/polvote"
> >>>>> username="root"
> >>>>> password="root"
> >>>>> batch-mode="false"
> >>>>> useAutoCommit="1"
> >>>>> ignoreAutoCommitExceptions="false"
> >>>>> >
> >>>>>
> >>>>> <object-cache
> >>>>>class="org.apache.ojb.broker.cache.ObjectCacheDefaultImpl">
> >>>>> <attribute attribute-name="timeout"
> attribute-value="900"/>
> >>>>> <attribute attribute-name="autoSync"
> >>>>
> >>>>attribute-value="true"/>
> >>>>
> >>>>> <attribute attribute-name="cachingKeyType"
> >>>>
> >>>>attribute-value="0"
> >>>>
> >>>>
> >>>>>/>
> >>>>> </object-cache>
> >>>>>
> >>>>> <connection-pool maxActive="21"
> >>>>> validationQuery="@VALIDATION_QUERY@"
> >>>>> testOnBorrow="@TEST_ON_BORROW@"
> >>>>> testOnReturn="@TEST_ON_RETURN@" />
> >>>>>
> >>>>> <sequence-manager
> >>>>>
> >>>>
> >
>
className="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
> >
> >>>>> <attribute attribute-name="grabSize"
> >>>>> attribute-value="20" />
> >>>>> <attribute attribute-name="autoNaming"
> >>>>> attribute-value="true" />
> >>>>> <attribute attribute-name="globalSequenceId"
> >>>>
> >>>>attribute-value="false" />
> >>>>
> >>>>> <attribute attribute-name="globalSequenceStart"
> >>>>
> >>>>attribute-value="10000"
> >>>>
> >>>>
> >>>>>/>
> >>>>> </sequence-manager>
> >>>>> </jdbc-connection-descriptor>
> >>>>>
> >>>>>The ojb.properties I did not change.
> >>>>>
> >>>>>It would be really nice if someone had an idea. I tested the whole
> day
> >>>>>yesterday and made no progress... :-(
> >>>>>
> >>>>>Thanks a lot,
> >>>>>Marko
> >>>>>
> >>>>
> >>>>---------------------------------------------------------------------
> >>>>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]
>
--
Marko H�bler
Untere Dorfstr. 7
02791 Oderwitz
Germany
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]