Hello,
I solved my problem. If anybody is interested in the solution:
PersistenceBroker aBroker = null;
ConnectionManagerIF aConnectionManager = null;
Connection aConnection = null;
String repositoryFile = null;
String param = "select * from foo";
Statement aStatement = null;
ResultSet aResultSet = null;
repositoryFile = "repository.xml";
PBKey key = new PBKey(repositoryFile);
aBroker = new PersistenceBrokerImpl(key,
PersistenceBrokerFactoryFactory.instance() );
aConnectionManager = aBroker.getConnectionManager();
aConnection = aConnectionManager.getConnection();
aStatement = aConnection.createStatement();
aStatement.execute(param);
aResultSet = aStatement.executeQuery(param);
Best regards
Boerries
.........................................................................
> -----Urspr�ngliche Nachricht-----
> Von: Ludwig, Boerries
> Gesendet: Sonntag, 1. September 2002 12:49
> An: 'OJB Users List'
> Betreff: AW: Simple SQL Query
>
>
> Hi,
>
> I have a similar problem. My application allows the
> administrator to query the database with SQL-statements. I
> had my own connections to HSQL, but now I get
> "java.sql.SQLException: The database is already in use by
> another process". The other process ist OJB.
>
> My questions are:
>
> 1. can I pass SQL-statements to OJB (the solution from Jakob
> does not help)
> 2. can I reuse a connection from OJBs connetion-pool to pass
> my query to
>
> Thanks in advance
>
> Boerries
>
> .............................
>
> hi ronen,
>
> you could also use a report query to retrieve simple column data:
>
> crit = new Criteria();
> crit.addEqualTo("name", "%er");
> query = new ReportQueryByCriteria(Person.class, crit);
> query.setColumns(new String[] { "sum(test)" });
> broker.getReportQueryIteratorByQuery(query);
>
> hth
> jakob
>
> ----- Original Message -----
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, August 07, 2002 2:32 PM
> Subject: Simple SQL Query
>
>
> > Hello everyone.
> >
> > i have a quick question which i'm sure you guys would know.
> > In my database, I have a table called "PRODUCTS" which has
> a column called
> > "ID". (this table maps to the persistent class
> Product.java). What i'm
> > simply trying to do is to use an sql statement to find out how many
> > products there are in the "PRODUCTS" table.
> >
> > The code I am using is:
> >
> > Criteria criteria = new Criteria();
> > criteria.addSql( "SELECT COUNT(ID) FROM PRODUCTS;" );
> >
> > The problem is that this sql statement should simply return
> a number, and
> > not an instance of the persistent class Product.java.
> However, it seems
> to
> > me like every Query object must be passed a persistent
> class which is to
> be
> > populated. In other words, the first parameter of every
> Query object
> (e.g.
> > QueryByCriteria, QueryBySQL, etc) has to be a persistent class.
> >
> > I have tried using Integer.class as the first parameter,
> but i receive a
> > ClassNotPersistenceCapableException.
> >
> >
> > Does anyone know how to handle such a simple request?
> >
> > Thanks for your help and time.
> > Ronen.
> >
> >
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>