I have done the 'ant build' and it makes no difference. If in the db.open()
I change to the "default" db alias the system appears not to see my
parameters at all. It has username and password set to null. There is
clearly something terribly obvious that I am just not understanding about
setting up OJB.

[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 com.gsk.bet.ConnectionTest.setUp(ConnectionTest.java:33)

As a background, I should explain that I am reasonably familiar with
Torque. I am in the process of evaluating whether to go with OJB, which
seems on paper to have some advantages over Torque, or whether to use
Torque also for this project. I really want database independence, so I
would prefer to use OJB.





|---------+--------------------------------->
|         |           "Brian McCallister"   |
|         |           <[EMAIL PROTECTED]|
|         |           ompany.com>           |
|         |                                 |
|         |                                 |
|         |           29-Mar-2004 17:34     |
|         |           Please respond to "OJB|
|         |           Users List"           |
|         |           <[EMAIL PROTECTED]|
|         |           g>                    |
|         |                                 |
|---------+--------------------------------->
  
>-------------------------------------------------------------------------------------------------------------------------|
  |                                                                                    
                                     |
  |                                                                                    
                                     |
  |                                                                                    
                                     |
  |       To:      "OJB Users List" <[EMAIL PROTECTED]>                                
                                |
  |                                                                                    
                                     |
  |       cc:                                                                          
                                     |
  |       Subject: Re: Newbie at a standstill                                          
                                     |
  
>-------------------------------------------------------------------------------------------------------------------------|



Are you using the ant build? The ojb-blank project template does a
property replace in the build -- the required database information is
in the build.properties and is copied into the generated
repository_database.xml that goes in build/ when compilation is run.

-Brian

On Mar 29, 2004, at 11:24 AM, [EMAIL PROTECTED] wrote:

> I am trying to get OJB working and am getting absolutely nowhere, so I
> appeal to the list for some help.
>
> The environment is OJB rc5, Eclipse IDE, Sun JDK1.4.2, Oracle 9,
> NT4.0. The
> running of the code is controlled by JUnit.
>
> I can connect to the DB both with sqlplus and jdbc. I cannot actually
> get
> OJB to connect. Clearly I am missing something, but I cannot discover
> what.
> By fiddling around  with the XML I can generate various sorts of
> errors. In
> all cases the url that the system is using appears to be entirely
> palusible.
>
> Here are the code, the repository_database.xml and the output:
>
> Code:
>
> /*
>  * Created on 26-Mar-2004
>  * CVS version $Header:$
>  */
> package com.gsk.bet;
>
> import java.util.*;
> import java.sql.*;
> import junit.framework.*;
> import org.apache.ojb.broker.*;
> import org.apache.ojb.broker.query.*;
> import org.odmg.*;
> import org.apache.ojb.odmg.*;
> import com.gsk.bet.Entity;
> /**
>  * @author rxm1676
>  * @company GSK
>  */
> public class ConnectionTest extends TestCase {
>       PersistenceBroker broker;
>       Database db = null;
>       Implementation odmg = null;
>
>       public void setUp() {
>
>             try {
>                   Class c =
> Class.forName("oracle.jdbc.driver.OracleDriver"
> );
>                   broker =
> PersistenceBrokerFactory.defaultPersistenceBroker();
>                   odmg = OJB.getInstance();
>                   db = odmg.newDatabase();
>                   db.open("BETConnection", Database.OPEN_READ_WRITE);
>             } catch (Exception ex) {
>                   System.out.println(ex);
>             }
>
>       }
>
>       public void tearDown() {
>             if (broker != null) {
>                   broker.close();
>             }
>             if (db != null) {
>                   try {
>                         db.close();
>                   } catch (ODMGException ex2) {
>                   }
>             }
>
>       }
>
>       /**
>        * Null test. Just checks that OJB is properly installed, that
> it can
> see both the
>        * XML and the bean classes, and that we can get a Broker and an
> ODMG
> instance.
>        *
>        */
>       public void testConnection() {
>       }
>
>
> /**
>  * Ensure that we can actually talk to the DB from this machine
>  *
>  */
> public void testRawJDBC()
> {
>    try {
>       Connection con = DriverManager.getConnection
>       ("jdbc:oracle:thin:@ukt01368.ggr.co.uk:1521:TOOLS", "bet",
> "xxxx");
>       PreparedStatement sth = con.prepareStatement("select * from
> entity
> where betid<10");
>       ResultSet res = sth.executeQuery();
>       System.out.println("Excuted raw query");
>       while (res.next()) {
>             Entity ent = new Entity();
>             ent.setBetid(res.getInt("BETID"));
>             ent.setEntityType(res.getString("ENTITYTYPE"));
>             ent.setDescriptor(res.getString("DESCRIPTOR"));
>             System.out.println("raw retrieval of "+ent);
>       }
>       res.close();
>       con.close();
>    } catch (Exception e) {
>       System.out.println("Caught raw exception " + e);
>   }
> }
>       /**
>        *
>        * @author rxm1676
>        * @company GSK
>        */
>       public void testODMGFetchSingle() {
>             Transaction tx = odmg.newTransaction();
>             try {
>
>                   OQLQuery query = odmg.newOQLQuery();
>                   query.create(
>                         "select betid, entityType, descriptor from " +
>                         Entity.class.getName() + " where betid = 1");
>                   DList results = (DList)query.execute();
>                   for (Iterator iter = results.iterator();
> iter.hasNext();)
> {
>                         tx.begin();
>                         Entity res = (Entity)iter.next();
>                         System.out.println("Retrieved " + res);
>                         tx.commit();
>                   }
>             } catch (QueryInvalidException qie) {
>                   System.out.println(qie);
>                   tx.abort();
>             } catch (QueryException qe) {
>                   System.out.println(qe);
>                   tx.abort();
>             }
>
>       }
>
>       /**
>        * Retrieve a single object using the PersistenceBroker
>        * @author rxm1676
>        * @company GSK
>        */
>       public void testPBFetchSingle()
>       {
>             Entity example = new Entity();
>             example.setBetid(1);
>             Query  q = QueryFactory.newQueryByExample(example);
>             Entity res = (Entity)broker.getObjectByQuery(q);
>             System.out.println("PB fetched "+res);
>       }
> }
>
> Database_repopsitory.xml
>
> <!-- @version $Id: repository_database.xml,v 1.17 2003/11/27 16:42:12
>
arminw Exp $ -->
> <!--
> Define here all used connections.
> One defined connection should be defined as the default one,
> by set default-connection="true" - this could be done at runtime too.
>
> It is possible to set user/password at
> runtime or let login different users at runtime using the same
> database. Use different PBKey with same jcdAlias name but
> different user/password.
>
> Ditto it is possible to add jdbc-connection-descriptor at runtime
> using the MetadataManager.
> -->
>
>     <!-- this connection was used as the default one within OJB -->
>     <jdbc-connection-descriptor
>             jcd-alias="@JCD_ALIAS@"
>             default-connection="false"
>             platform="@DBMS_NAME@"
>             jdbc-level="@JDBC_LEVEL@"
>             driver="@DRIVER_NAME@"
>             protocol="@URL_PROTOCOL@"
>             subprotocol="@URL_SUBPROTOCOL@"
>             dbalias="@URL_DBALIAS@"
>             username="@USER_NAME@"
>             password="@USER_PASSWD@"
>         eager-release="false"
>             batch-mode="false"
>         useAutoCommit="1"
>         ignoreAutoCommitExceptions="false"
>>
>
>         <connection-pool
>             maxActive="21"
>             validationQuery="" />
>
>         <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>
>
>    <!-- Datasource example -->
>     <!-- jdbc-connection-descriptor
>         jcd-alias="default"
>
default-connection="false"
>             platform="Hsqldb"
>
jdbc-level="2.0"
>             jndi-datasource-name="java:DefaultDS"
>
username="sa"
>             password=""
>             eager-release="false"
>         batch-mode="false"
>         useAutoCommit="0"
>
ignoreAutoCommitExceptions="false"
>>
>         <sequence-manager className
> ="org.apache.ojb.broker.util.sequence.SequenceManagerNextValImpl">
>
<attribute attribute-name="autoNaming"  
> attribute-value="true"/>
>
</sequence-manager>
>
>    </jdbc-connection-descriptor -->
>
>
>
>     <!--
>         NOTE: This is a test descriptor used within
>         the junit test suite, do not change any value.
>         A test db connections used for junit tests.
>         This connection matches a hsql database called 'OJB_FarAway'
>         If you do not use the test suite, you could delete
>         this descriptor.
>         This descriptor was used to check multiple database
>         use.
>     -->
>     <jdbc-connection-descriptor
>         jcd-alias="farAway"
>         platform="Hsqldb"
>         jdbc-level="2.0"
>         driver="org.hsqldb.jdbcDriver"
>         protocol="jdbc"
>         subprotocol="hsqldb"
>         dbalias="../OJB_FarAway"
>         username="sa"
>         password=""
>         batch-mode="false"
>>
>
>         <connection-pool
>             maxActive="6"
>             whenExhaustedAction="0"
>             validationQuery="select count(*) from OJB_HL_SEQ"
>         />
>
>         <sequence-manager className
> ="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
>             <attribute attribute-name="grabSize" attribute-value="5"/>
>         </sequence-manager>
>     </jdbc-connection-descriptor>
>
>     <!--
>         NOTE: This is a test descriptor used within
>         the junit test suite, do not change any value.
>         If you do not use the test suite, you could
>         delete this descriptor.
>         In the the test directory under
>
> org.apache.ojb.broker.metadata.MetadataTest#testReadConnectionDescripto
> r
>         this descriptor will be evaluated.
>     -->
>     <jdbc-connection-descriptor
>         jcd-alias="BETConnection"
>         default-connection="true"
>         platform="oracle"
>         jdbc-level="2.0"
>         driver="oracle.jdbc.driver.OracleDriver"
>         protocol="jdbc"
>         subprotocol="oracle:thin"
>         dbalias="@ukt01368.ggr.co.uk:1521:TOOLS"
>         username="bet"
>         password="xxxx"
>         eager-release="true"
>         batch-mode="true"
>         useAutoCommit="0"
>         ignoreAutoCommitExceptions="true"
>>
>
>         <object-cache class
> ="org.apache.ojb.broker.cache.ObjectCacheEmptyImpl">
>             <attribute attribute-name="cacheKey1" attribute-value
> ="cacheValue1"/>
>             <attribute attribute-name="cacheKey2" attribute-value
> ="cacheValue2"/>
>         </object-cache>
>
>         <connection-pool
>             maxActive="1"
>             maxIdle="2"
>             maxWait="3"
>             minEvictableIdleTimeMillis="4"
>             numTestsPerEvictionRun="5"
>             testOnBorrow="true"
>             testOnReturn="true"
>             testWhileIdle="true"
>             timeBetweenEvictionRunsMillis="6"
>             whenExhaustedAction="2"
>             validationQuery="a query"
>             logAbandoned="true"
>             removeAbandoned="true"
>             removeAbandonedTimeout="8"
>         />
>
>         <sequence-manager className
> ="org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl">
>             <attribute attribute-name="key1" attribute-value="value1"/>
>             <attribute attribute-name="key2" attribute-value="value2"/>
>         </sequence-manager>
>     </jdbc-connection-descriptor>
>
>
> Output:
>
> Excuted raw query
> raw retrieval of BET ID: 1 EntityType: Protein Descriptor;null
> raw retrieval of BET ID: 2 EntityType: Protein Descriptor;null
> raw retrieval of BET ID: 3 EntityType: Protein Descriptor;null
> raw retrieval of BET ID: 4 EntityType: Protein Descriptor;null
> raw retrieval of BET ID: 5 EntityType: Protein Descriptor;null
> raw retrieval of BET ID: 6 EntityType: Protein Descriptor;null
> raw retrieval of BET ID: 7 EntityType: Protein Descriptor;null
> raw retrieval of BET ID: 8 EntityType: Protein Descriptor;null
> raw retrieval of BET ID: 9 EntityType: Protein Descriptor;null
> [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
> (Unknown
>
> 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(Unkno
> wn
> Source)
>       at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getRsIteratorFromQuery
> (Unknown
>
> Source)
>       at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getIteratorFromQuery(U
> nknown
>
> Source)
>       at
> org.apache.ojb.broker.core.PersistenceBrokerImpl.getObjectByQuery(Unkno
> wn
> Source)
>       at
> org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery
> (Unknown
>
> Source)
>       at
> org.apache.ojb.broker.core.DelegatingPersistenceBroker.getObjectByQuery
> (Unknown
>
> Source)
>       at
> com.gsk.bet.ConnectionTest.testPBFetchSingle(ConnectionTest.java:127)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja
> va:39)
>       at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso
> rImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:324)
>       at junit.framework.TestCase.runTest(TestCase.java:154)
>       at junit.framework.TestCase.runBare(TestCase.java:127)
>       at junit.framework.TestResult$1.protect(TestResult.java:106)
>       at junit.framework.TestResult.runProtected(TestResult.java:124)
>       at junit.framework.TestResult.run(TestResult.java:109)
>       at junit.framework.TestCase.run(TestCase.java:118)
>       at junit.framework.TestSuite.runTest(TestSuite.java:208)
>       at junit.framework.TestSuite.run(TestSuite.java:203)
>       at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteT
> estRunner.java:392)
>       at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRu
> nner.java:276)
>       at
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestR
> unner.java:167)
> Caused by: org.apache.ojb.broker.accesslayer.LookupException: Could not
> borrow connection from pool -
> org.apache.ojb.broker.metadata.JdbcConnectionDescriptor:
> [EMAIL PROTECTED]
>   jcd-alias=BETConnection
>   default-connection=true
>   dbms=oracle
>   jdbc-level=2.0
>   driver=oracle.jdbc.driver.OracleDriver
>   protocol=jdbc
>   sub-protocol=oracle:thin
>   [EMAIL PROTECTED]:1521:TOOLS
>   user=bet
>   password=*****
>   eager-release=true
>   ConnectionPoolDescriptor={whenExhaustedAction=2, validationQuery=a
> query,
> maxIdle=2, maxActive=1, maxWait=3, removeAbandoned=true,
> numTestsPerEvictionRun=5, testWhileIdle=true,
> minEvictableIdleTimeMillis=4,
> testOnReturn=true, logAbandoned=true, removeAbandonedTimeout=8,
> timeBetweenEvictionRunsMillis=6, testOnBorrow=true}
>   batchMode=true
>   useAutoCommit=AUTO_COMMIT_IGNORE_STATE
>   ignoreAutoCommitExceptions=true
>
> [EMAIL PROTECTED]
> 3118a
>
>
>      sequenceManagerClass=class
> org.apache.ojb.broker.util.sequence.SequenceManagerHighLowImpl
>      Properties={key2=value2, key1=value1}
> ]
> ]
>       at
> org.apache.ojb.broker.accesslayer.ConnectionFactoryPooledImpl.getConnec
> tionFromPool(Unknown
>
> Source)
>       at
> org.apache.ojb.broker.accesslayer.ConnectionFactoryAbstractImpl.lookupC
> onnection(Unknown
>
> Source)
>       at
> org.apache.ojb.broker.accesslayer.ConnectionManagerImpl.getConnection(U
> nknown
>
> Source)
>       ... 26 more
> Caused by: java.util.NoSuchElementException: Could not create a
> validated
> object
>       at
> org.apache.commons.pool.impl.GenericObjectPool.borrowObject(GenericObje
> ctPool.java:851)
>       ... 29 more
>
>
>
>
> ---------------------------------------------------------------------
> 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]

Reply via email to