Dear all,
            Any one how to fetch a specific row in a oracle by using primary key.I 
tried using the following code:
public static void main(String[] dhamu)
 {
      Implementation odmg = OJB.getInstance();
     Database db= odmg.newDatabase();
   java.util.Iterator iter=null;
      try
        {
            String bindVar="3";//my primary key
            file://open database
            db.open("repository.xml", Database.OPEN_READ_WRITE);
            // 1. open a transaction
            Transaction tx = odmg.newTransaction();
            tx.begin();
            // 2. get an OQLQuery object from the ODMG facade
            OQLQuery query = odmg.newOQLQuery();
            // 3. set the OQL select statement
            String oqlQuery="select specifyvalue from " + Product.class.getName()+" 
where id=$1";
            System.out.println(oqlQuery);
            query.create(oqlQuery);
            query.bind(bindVar);
            // 4. perform the query and store the result in a persistent Collection
            DList allDetails = (DList)query.execute();
            tx.commit();
            // 5. now iterate over the result to print each product
                  iter = allDetails.iterator();
                  while(iter.hasNext())
                  {
                  Product product=(Product)iter.next();
                  System.out.println("Price = "+product.getName());
                   System.out.println("Price = "+product.getPrice());
                    System.out.println("Stock = "+product.getStock());
                  }

        }
        catch (ODMGException ex)
        {
            ex.printStackTrace();
        }
 }
I facing the error: [org.apache.ojb.broker.accesslayer.JdbcAccess] ERROR: SQLException 
during the execution of the query: ORA-01036: illegal variable name/number
Thanks with regards
Dhamu
 
 
 
 Dhamodharan P <[EMAIL PROTECTED]> wrote:
Hi Kennedy,
For ORACLE Sequence:(no need to change anything repository_user.xml).Just generate 
sequence and a trigger as follows for your table:
CREATE SEQUENCE 

START WITH 1
INCREMENT BY 1
NOMAXVALUE;


CREATE TRIGGER 
BEFORE INSERT ON 
FOR EACH ROW
BEGIN
SELECT .NEXTVAL INTO :NEW. FROM DUAL;
END;
/
For OJB AUTOINCREMENT:you need to set repository_user.xml as follows

class="com.cit.ojb."
table=">
name=""
column=""
jdbc-type="INTEGER"
primarykey="true"
autoincrement="true"
/>

- - - - - - 

- - - - - 

- --

if it works just reply me.

Regards

Dhamu



Ryan Kennedy wrote: For some reason I can't seem to get the Oracle sequence manager to 
work. I
have the following in my OJB.properties:


SequenceManagerClass=org.apache.ojb.broker.util.sequence.SequenceManagerOracl
eImpl

I have this in my repository_user.xml:



I construct a new Job object and call broker.store(job); to persist it to the
database. When I do that, I get the following exception:

java.lang.Exception: sequence-name attribute is not defined in 
the class descriptor - Job

It appears that it can't find my sequence-name attribute, but I have it there
in my class descriptor. Any ideas?

Ryan Kennedy
Software Engineer
Jel, Inc.
web. www.jel.net

--
To unsubscribe, e-mail: 
For additional commands, e-mail: 




---------------------------------
Get a bigger mailbox -- choose a size that fits your needs.
etch 



---------------------------------
Get a bigger mailbox -- choose a size that fits your needs.

Reply via email to