Hi Guys,

I'm just upgrading 'working' software to 0.9.8. I've cleaned my classpath,
and updated my config files. I'm using OJB 0.9.8 (ODMG), with a recent
MySQL release, and SDK1.4.1 (using IntelliJ IDEA as an environment). The
OJB build works okay both against HSQL (163 tests, no fails, no errors),
and against MySQL (163 tests, 3 fails, 2 errors), and the tests all seem to
pass. My database is correctly populated with the OJB management tables
(exported out of the test database before the tests are run).

I'm not sure, but I think this may be a connection problem. I've included
as much material here as I can find. Thanks in advanced for any help you
can provide.

Here is the output I'm getting (including the invocation line for the app):

F:\jdk\bin\javaw.exe -classpath
F:\jdk\jre\lib\charsets.jar;F:\jdk\jre\lib\jaws.jar;F:\jdk\jre\lib\jce.jar;
F:\jdk\jre\lib\jsse.jar;F:\jdk\jre\lib\rt.jar;F:\jdk\jre\lib\sunrsasign.jar
;F:\jdk\jre\lib\ext\dnsns.jar;F:\jdk\jre\lib\ext\ldapsec.jar;F:\jdk\jre\lib
\ext\localedata.jar;F:\jdk\jre\lib\ext\sunjce_provider.jar;D:\Dev\wiki\src\
config;D:\Dev\wiki\classes;D:\tools\jakarta-ojb-0.9.8\lib\antlr.jar;D:\tool
s\jakarta-ojb-0.9.8\lib\commons-collections-2.0.jar;D:\tools\jakarta-ojb-0.
9.8\lib\commons-lang-1.0-mod.jar;D:\tools\jakarta-ojb-0.9.8\lib\commons-poo
l.jar;D:\tools\jakarta-ojb-0.9.8\lib\jakarta-ojb-0.9.8.jar;D:\tools\Jakarta
\oro\jakarta-oro-2.0.5.jar;D:\tomcat\common\lib\servlet.jar;D:\tools\junit3
.8\junit.jar;D:\MySQL\mysql-connector-java-2.0.14\mysql-connector-java-2.0.
14-bin.jar Main

[org.apache.ojb.broker.ta.PersistenceBrokerFactoryDefaultImpl] INFO: Create
PersistenceBroker instance pool, pool configuration was
{whenExhaustedAction=0, maxIdle=-1, maxActive=100, maxWait=2000,
numTestsPerEvictionRun=10, testWhileIdle=false, testOnReturn=false,
timeBetweenEvictionRunsMillis=-1, minEvictableIdleIimeMillis=600000,
testOnBorrow=false}

[org.apache.ojb.broker.util.sequence.SequenceManagerFactory] INFO: Use
sequence manager class: class
org.apache.ojb.broker.util.sequence.SequenceManagerHiLoImpl

java.lang.NullPointerException
        at org.apache.ojb.odmg.oql.OQLQueryImpl.create(Unknown Source)
        at org.apache.ojb.odmg.oql.OQLQueryImpl.create(Unknown Source)
        at com.softed.PersistenceManager.queryNoTx(PersistenceManager.java:71)
        at com.softed.PersistenceManager.query(PersistenceManager.java:59)
        at com.softed.PersistenceManager.doQuery(PersistenceManager.java:52)
        at Main.main(Main.java:11)
Exception in thread "main" Process terminated with exit code 1


-----------
And here's the config files I'm using:

Repository.xml
<descriptor-repository version="0.9.8" isolation-level="read-uncommitted">
    <jdbc-connection-descriptor
        platform="MySQL"
        jdbc-level="2.0"
        driver="com.mysql.jdbc.Driver"
        protocol="jdbc"
        subprotocol="mysql"
        dbalias="//localhost:3306/wiki2"
        username="root"
        password=""
        eager-release="false"  />

    &user;
    &internal;
</descriptor-repository>

---------------------------
repository_user.xml
---------------------------
<class-descriptor class="com.softed.Page" table="PAGE">
        <field-descriptor id="1" name="id" column="ID" jdbc-type="INTEGER"
primarykey="true" autoincrement="true"/>
        <field-descriptor id="2" name="name" column="NAME" jdbc-type="VARCHAR" />
        <field-descriptor id="3" name="contents" column="CONTENTS"
jdbc-type="VARCHAR" />
        <field-descriptor id="4" name="lastChanged" column="LASTCHANGED"
jdbc-type="TIMESTAMP"/>
        <field-descriptor id="5" name="locked" column="LOCKED" jdbc-type="INTEGER"
conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldC
onversion"/>
</class-descriptor>


Both of these files are in my classpath, along with the other xml files,
and the dtd, in their unaltered form.

The query, and the code is tivial:

---------------------------
Main
---------------------------
PersistenceManager pm = new PersistenceManager();
pm.connect();
final Iterator iterator = pm.doQuery("select pages from Page");
while (iterator.hasNext()) {
  Page page = (Page) iterator.next();
  System.out.println("page.getName() = " + page.getName());
}
---------------------------

---------------------------
PersisenceManager
---------------------------
import org.apache.ojb.odmg.*;
import org.apache.oro.text.perl.Perl5Util;
import org.odmg.*;

import java.util.Iterator;
import java.util.Vector;

public class PersistenceManager {
    private Implementation odmg;
    private Database db;
    private Transaction tx;

    public void connect() {
        if (db != null) return;
        odmg = OJB.getInstance();
        db = odmg.newDatabase();
        try {
            db.open("repository.xml", Database.OPEN_READ_WRITE);
        } catch (ODMGException e) {
            e.printStackTrace();
        }
    }

    public void startTX() {
        tx = odmg.newTransaction();
        tx.begin();
    }

    public Iterator doQuery(String queryText) {
        return query(queryText).iterator();
    }

    private DList query(String queryText) {
        connect();
        startTX();
        DList quertyResults = queryNoTx(queryText);
        commit();
        return quertyResults;
    }

    private DList queryNoTx(String queryText) {
        OQLQuery query = odmg.newOQLQuery();
        DList quertyResults = null;

        try {
            query.create(queryText);
            quertyResults = (DList) query.execute();
        } catch (QueryException e) {
            e.printStackTrace();
        }

        return quertyResults;
    }

    ...
}

---------------------------
The Page class is a very basic bean.

Any ideas would be greatfully received.

Cheers,

Bryan



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

Reply via email to