db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sheng Guo <sh...@in.tum.de>
Subject Problem with Insert records to the database
Date Mon, 09 Feb 2004 16:07:48 GMT
Hello,

I am doing a web application project with Turbine2.3+Velocity+Torque. As 
a database I have PostgreSQL 7.2.  As I tried to insert the data, which 
I collected from the web page, there was alway an exception:

org.apache.torque.TorqueException: ERROR: cnt_test_seq.currval is not 
yet defined in this session

the cnt_test_seq was already defined in the database, but I don't have 
the "currval" anywhere in the database. How can that happen?

I followed the tutorial on the Torque site to write the code, but it 
didn't work. I had the following code in my Java file:

//name of the method, which did the insert
public void doSavedata(RunData data, Context context) {

    //collect data from the Velocity template
    String name = data.getParameters().getString("name");
    String beschreibung = data.getParameters().getString("beschreibung");
    String identifikator = data.getParameters().getString("identifikator");
    String gueltigkeit = data.getParameters().getString("gueltigkeit");
  
    CNTTest ct = new CNTTest();  //The om class, which was generated by 
Torque
  
     //set the attributes of the instance of CNTTest
     Integer id = new Integer(2);
    ct.setId(id);
    ct.setName(name);
    ct.setDescription(beschreibung);
    ct.setAttributeType(identifikator);
    Integer g = new Integer(5);
    ct.setSortOrder(g);
  
    //save in to the database.
    try {
      ct.save();
      System.out.println("save ok");
      context.put("status", "sucess");
      System.out.println("context--sucess");
    }
    catch (Exception ex) {
      String message = ex.toString();
      System.out.println(message);
      ex.printStackTrace();
      context.put("status", "failed");
      context.put("message", message);
      System.out.println("context--failed");
    }

I am looking forward to hearing from your earliest reply!

yours sincerely

Guo


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


Mime
View raw message