Greetings,

I keep getting an error stating that "OJB can't open database".
However I'm sure the repository.xml file is in the classpath. I've put
several evenings into to figuring this out and am unable to find a
solution. It seems like it is unable to find the repository.xml file.
I initially try this in a Struts project but I thought that maybe that
fact that some of the depended libraries were a higher version then
what came with the 1.0.1 download that this might be messing things
up. I then moved it to a two class project in eclipse and added all
the libraries that came with OJB 1.0.1, and I received the same error.

Thanks for any Help!
Phillip Blevins

here is my connection code
 public static void storeCountry()
{
  CountryVO cc = new CountryVO();
  cc.setArms(10);
  cc.setArtisans(10);
  cc.setDefense(11);
  cc.setName("Chi Chan");
  cc.setNumber(10);

    Implementation odmg = OJB.getInstance();
Database db = odmg.newDatabase();

  try{
      //db.open("default#pblevins#friend", Database.OPEN_READ_WRITE);
      //db.open("repository.xml", Database.OPEN_READ_WRITE);
     db.open("default", Database.OPEN_READ_WRITE);
    }catch (ODMGException ex){
      ex.printStackTrace();
   }

/* ... use the database ... */

try{
Implementation impl = OJB.getInstance();
Transaction tx = impl.newTransaction();
tx.begin();
tx.lock(cc, Transaction.WRITE);
tx.commit();

db.close();
  }catch (org.odmg.ODMGException ee){
     ee.printStackTrace();
 }
}

This Would be my error:

(core.PersistenceBrokerFactoryDefaultImpl ?   ) Create
PersistenceBroker instance pool, pool configuration was
{whenExhaustedAction=0, maxIdle=-1, maxActive=100, maxWait=2000,
removeAbandoned=false, numTestsPerEvictionRun=10, testWhileIdle=false,
minEvictableIdleTimeMillis=1000000, testOnReturn=false,
logAbandoned=false, removeAbandonedTimeout=300,
timeBetweenEvictionRunsMillis=-1, testOnBorrow=false}
(metadata.RepositoryPersistor        ?   ) OJB Descriptor Repository:
file:/C:/Program%20Files/eclipse3.0/workspace/TSSt/bin/repository.xml
(metadata.RepositoryPersistor        ?   ) Building repository from
:file:/C:/Program%20Files/eclipse3.0/workspace/TSSt/bin/repository.xml
(metadata.MetadataManager            ?   ) No repository.xml file
found, starting with empty metadata and connection configuration
(metadata.MetadataManager            ?   ) No 'default-connection'
attribute set in jdbc-connection-descriptors, thus it's currently not
possible to use 'defaultPersistenceBroker()'  convenience method to
lookup PersistenceBroker instances. But it's possible to enable this
at runtime using 'setDefaultKey' method.
(metadata.ConnectionRepository       ?   ) Could not find
org.apache.ojb.broker.metadata.JdbcConnectionDescriptor for PBKey
org.apache.ojb.broker.PBKey: jcdAlias=default, user=null,
password=null
(odmg.DatabaseImpl                   ?   ) Open database failed:
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 CountryDA.main(CountryDA.java:33)
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 CountryDA.main(CountryDA.java:33)
org.odmg.DatabaseClosedException: Database is NULL, must have a DB in
order to create a transaction
        at org.apache.ojb.odmg.ImplementationImpl.newTransaction(Unknown Source)
        at CountryDA.main(CountryDA.java:42)
Exception in thread "main"
<?xml version="1.0" encoding="UTF-8"?>
<!--
#/* Copyright 2002-2004 The Apache Software Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
-->
<!-- This is a sample metadata repository for the
     Apache ObJectRelationalBridge (OJB) System.
     Use this file as a template for building your own mappings.
-->

<!-- doctype definition
     By default we are using a local DTD that is expected to reside
     in the same directory as this repository.xml file.
     If you intend to validate your repository.xml against
     the public dtd at the Apache site, please replace the string
     "repository.dtd"
     by the public adress
     "http://db.apache.org/ojb/dtds/1.0/repository.dtd";.
     In this case validation will only work if the machine you
     run your application on can connect to the internet!
-->

<!DOCTYPE descriptor-repository PUBLIC
       "-//Apache Software Foundation//DTD OJB Repository//EN"
       "repository.dtd"
[

<!ENTITY database SYSTEM "repository_database.xml">
<!ENTITY internal SYSTEM "repository_internal.xml">
<!ENTITY user SYSTEM "repository_user.xml">
]>


<descriptor-repository version="1.0"
                       isolation-level="read-uncommitted"
                       proxy-prefetching-limit="50">

    <!-- include all used database connections -->
    &database;

    <!-- include ojb internal mappings here; comment this if you don't need them -->
    <!-- &internal; -->

    <!-- include user defined mappings here -->
    &user;
</descriptor-repository>


    <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/genghiskhan"
   		username="pblevins"
   		password="friend"
   		batch-mode="false" />



 
<!-- Please keep user defined mappings in this file only
     to avoid mixing user defined and system mappings. -->
<!-- Mapping of User defined classes starts here -->


<class-descriptor class="com.mrbelvins.game.CountryVO" table="country">

        <field-descriptor name="idGame" column="idGame" />
        <field-descriptor name="number" column="number" />
        <field-descriptor name="name" column="name" />
        <field-descriptor name="gold" column="gold" />
        <field-descriptor name="food" column="food" />
        <field-descriptor name="troops" column="troops" />
        <field-descriptor name="town" column="town" />
        <field-descriptor name="masons" column="masons" />
        <field-descriptor name="farmers" column="farmers" />
        <field-descriptor name="artisans" column="artisans" />
        <field-descriptor name="morale" column="morale" />
        <field-descriptor name="economy" column="economy" />
        <field-descriptor name="defense" column="defense" />
        <field-descriptor name="arms" column="arms" />
        <field-descriptor name="skill" column="skill" />





 </class-descriptor>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to