You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by David E Noel <de...@us.ibm.com> on 2003/01/28 00:39:53 UTC
Database schema within DB2
Well I'm most of the way to getting Torque to work with DB2 and my
generated OM classes (I think). I am having a problem with Torque and DB2
schemas.
in my main application I have the following code
Torque.init("Torque.properties"); // in here I set up my default
connection to a DB2 database.
StepDefinition sd=new StepDefinition(); //This is one of my OM classes
sd.setCol1("asd");
sd.setCol2("kjdsf");
sd.save();
The save method throws the following exception
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/6000] SQL0204N
"MYUSER.STEP_DEFINITION" is an undefined name. SQLSTATE=42704
at
COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(SQLExceptionGenerator.java:264)
at
COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(SQLExceptionGenerator.java:207)
at
COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(SQLExceptionGenerator.java:446)
at
COM.ibm.db2.jdbc.app.DB2Statement.execute2(DB2Statement.java:786)
at
COM.ibm.db2.jdbc.app.DB2Statement.executeQuery(DB2Statement.java:549)
at com.workingdogs.village.Schema.schema(Unknown Source)
at com.workingdogs.village.Schema.schema(Unknown Source)
at com.workingdogs.village.DataSet.<init>(Unknown Source)
at com.workingdogs.village.TableDataSet.<init>(Unknown Source)
at org.apache.torque.util.BasePeer.doInsert(BasePeer.java:723)
at
com.blah.torque.BaseStepDefinitionPeer.doInsert(BaseStepDefinitionPeer.java:225)
at
com.blah.torque.BaseStepDefinitionPeer.doInsert(BaseStepDefinitionPeer.java:581)
at
com.blah.torque.BaseStepDefinition.save(BaseStepDefinition.java:460)
at
com.blah.torque.BaseStepDefinition.save(BaseStepDefinition.java:422)
at
com.blah.torque.BaseStepDefinition.save(BaseStepDefinition.java:402)
at LTest.main(LTest.java:18)
the table MYUSER.STEP_DEFINITION does not exist but TEST.STEP_DEFINITON
does. Torque is using the current default schema of DB2. MYUSER is the
default because it is the userid I connect to the database with.
I have been able to get around this by changing my code to
Torque.init("Torque.properties");
Connection con=Torque.getConnection();
Statement s=con.createStatement();
s.execute("set current schema TEST");
StepDefinition sd=new StepDefinition();
sd.setCol1("asd");
sd.setCol2("kjdsf");
sd.save(con);
con.commit();
This is really messy though. Am I missing something? Is there a way to
set the schema within the Torque Framework? Ideally there would be a way
to optionally define a default schema in the Torque XML schema file and a
way to programmatically change this setting as the program is running.
Thanks In Advance
Dave