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 Rolf Pfister <ro...@gmx.net> on 2003/12/03 20:07:54 UTC

Problems with OQLQuery

Hi all,

Each time when create a OQL Query with
	OQLQuery query = odmg.newOQLQuery(); 
I get the following error message:
java.lang.NoClassDefFoundError: antlr/TokenStreamException
	at org.apache.ojb.odmg.OJB.newOQLQuery(Unknown Source)
	at
ch.lcu.mycoach.data.MemberFactory.getMemberDO(MemberFactory.java:56)
...

Whats wrong? The same query is working when I use the PersistenceBroker
implementation. Can anybody help me?
I'm working with ojb-1.0.rc4.

Thanks for your help!

Rolf


NB:This is the code of the MemberFactory class:

package ch.lcu.mycoach.data;

import org.apache.ojb.odmg.OJB;
import org.odmg.*
import ch.lcu.mycoach.entities.Member;


public class MemberFactory {

	Implementation odmg = null;
	Database db = null;
	Member member = new Member();

	public MemberFactory() {
		// get odmg facade instance
		odmg = OJB.getInstance();
		db = odmg.newDatabase();
		//open database
		try {
			db.open("mycoach", Database.OPEN_READ_WRITE);
		} catch (ODMGException ex) {
			ex.printStackTrace();
		}

	}

	public Member getMemberDO(String username, String password) {
		Transaction tx = odmg.newTransaction();
		try {
			// 1. open a transaction
			tx.begin();

			// 2. get an OQLQuery object from the ODMG
facade
			OQLQuery query = odmg.newOQLQuery();

			// 3. set the OQL select statement
			String queryStr = "select members from " +
Member.class.getName();
			queryStr += " where username = $1 adn password =
$2";
			
			
			query.create(queryStr);
			query.bind(username);
			query.bind(password);
			// 4. perform the query and store the result
			// in a persistent Collection
			DList members = (DList) query.execute();
			member = (Member) members.get(0);
			tx.commit();

		} catch (Throwable t) {
			// rollback in case of errors
			tx.abort();
			t.printStackTrace();
		}

		return member;
	}
}





---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-user-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-user-help@db.apache.org


AW: Problems with OQLQuery

Posted by Rolf Pfister <ro...@gmx.net>.
That was it! Thanks to your help!

Rolf

-----Ursprüngliche Nachricht-----
Von: Jakob Braeuchi [mailto:jbraeuchi@gmx.ch] 
Gesendet: Mittwoch, 3. Dezember 2003 21:17
An: OJB Users List
Betreff: Re: Problems with OQLQuery

hi rolf,

do you have antl.jar or antlr.debug.jar in your classpath ?

jakob

Rolf Pfister wrote:
> Hi all,
> 
> Each time when create a OQL Query with
> 	OQLQuery query = odmg.newOQLQuery(); 
> I get the following error message:
> java.lang.NoClassDefFoundError: antlr/TokenStreamException
> 	at org.apache.ojb.odmg.OJB.newOQLQuery(Unknown Source)
> 	at
> ch.lcu.mycoach.data.MemberFactory.getMemberDO(MemberFactory.java:56)
> ...
> 
> Whats wrong? The same query is working when I use the
PersistenceBroker
> implementation. Can anybody help me?
> I'm working with ojb-1.0.rc4.
> 
> Thanks for your help!
> 
> Rolf
> 
> 
> NB:This is the code of the MemberFactory class:
> 
> package ch.lcu.mycoach.data;
> 
> import org.apache.ojb.odmg.OJB;
> import org.odmg.*
> import ch.lcu.mycoach.entities.Member;
> 
> 
> public class MemberFactory {
> 
> 	Implementation odmg = null;
> 	Database db = null;
> 	Member member = new Member();
> 
> 	public MemberFactory() {
> 		// get odmg facade instance
> 		odmg = OJB.getInstance();
> 		db = odmg.newDatabase();
> 		//open database
> 		try {
> 			db.open("mycoach", Database.OPEN_READ_WRITE);
> 		} catch (ODMGException ex) {
> 			ex.printStackTrace();
> 		}
> 
> 	}
> 
> 	public Member getMemberDO(String username, String password) {
> 		Transaction tx = odmg.newTransaction();
> 		try {
> 			// 1. open a transaction
> 			tx.begin();
> 
> 			// 2. get an OQLQuery object from the ODMG
> facade
> 			OQLQuery query = odmg.newOQLQuery();
> 
> 			// 3. set the OQL select statement
> 			String queryStr = "select members from " +
> Member.class.getName();
> 			queryStr += " where username = $1 adn password =
> $2";
> 			
> 			
> 			query.create(queryStr);
> 			query.bind(username);
> 			query.bind(password);
> 			// 4. perform the query and store the result
> 			// in a persistent Collection
> 			DList members = (DList) query.execute();
> 			member = (Member) members.get(0);
> 			tx.commit();
> 
> 		} catch (Throwable t) {
> 			// rollback in case of errors
> 			tx.abort();
> 			t.printStackTrace();
> 		}
> 
> 		return member;
> 	}
> }
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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: Problems with OQLQuery

Posted by Jakob Braeuchi <jb...@gmx.ch>.
hi rolf,

do you have antl.jar or antlr.debug.jar in your classpath ?

jakob

Rolf Pfister wrote:
> Hi all,
> 
> Each time when create a OQL Query with
> 	OQLQuery query = odmg.newOQLQuery(); 
> I get the following error message:
> java.lang.NoClassDefFoundError: antlr/TokenStreamException
> 	at org.apache.ojb.odmg.OJB.newOQLQuery(Unknown Source)
> 	at
> ch.lcu.mycoach.data.MemberFactory.getMemberDO(MemberFactory.java:56)
> ...
> 
> Whats wrong? The same query is working when I use the PersistenceBroker
> implementation. Can anybody help me?
> I'm working with ojb-1.0.rc4.
> 
> Thanks for your help!
> 
> Rolf
> 
> 
> NB:This is the code of the MemberFactory class:
> 
> package ch.lcu.mycoach.data;
> 
> import org.apache.ojb.odmg.OJB;
> import org.odmg.*
> import ch.lcu.mycoach.entities.Member;
> 
> 
> public class MemberFactory {
> 
> 	Implementation odmg = null;
> 	Database db = null;
> 	Member member = new Member();
> 
> 	public MemberFactory() {
> 		// get odmg facade instance
> 		odmg = OJB.getInstance();
> 		db = odmg.newDatabase();
> 		//open database
> 		try {
> 			db.open("mycoach", Database.OPEN_READ_WRITE);
> 		} catch (ODMGException ex) {
> 			ex.printStackTrace();
> 		}
> 
> 	}
> 
> 	public Member getMemberDO(String username, String password) {
> 		Transaction tx = odmg.newTransaction();
> 		try {
> 			// 1. open a transaction
> 			tx.begin();
> 
> 			// 2. get an OQLQuery object from the ODMG
> facade
> 			OQLQuery query = odmg.newOQLQuery();
> 
> 			// 3. set the OQL select statement
> 			String queryStr = "select members from " +
> Member.class.getName();
> 			queryStr += " where username = $1 adn password =
> $2";
> 			
> 			
> 			query.create(queryStr);
> 			query.bind(username);
> 			query.bind(password);
> 			// 4. perform the query and store the result
> 			// in a persistent Collection
> 			DList members = (DList) query.execute();
> 			member = (Member) members.get(0);
> 			tx.commit();
> 
> 		} catch (Throwable t) {
> 			// rollback in case of errors
> 			tx.abort();
> 			t.printStackTrace();
> 		}
> 
> 		return member;
> 	}
> }
> 
> 
> 
> 
> 
> ---------------------------------------------------------------------
> 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