db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robles, Rogelio" <rogelio.rob...@experian.com>
Subject RE: Database schema within DB2
Date Tue, 28 Jan 2003 22:43:04 GMT


> -----Original Message-----
> From: David E Noel [mailto:denoel@us.ibm.com]
> Sent: Monday, January 27, 2003 3:40 PM
> Subject: Database schema within DB2
> 
...
> 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
> 

I haven't found how to tell Torque to use DB2 schemas automatically every
time that I request a db connection. What I'm doing is to set the schema to
a Connection and use it from that point forward:


      // start Torque database engine
      Torque.init(TORQUE_CONFIG);

      // start a transaction
      m_Connection = Transaction.begin(Torque.getDefaultDB());

	// set the schema first reading it from a properties file
      String schema = m_Properties.getString("DbSchema");
      BasePeer.executeStatement("set schema " + schema, m_Connection);

	....
	from here I use the Torque API functions that require a Connection
as a parameter
	once that I commit the transaction, I start all over again
	....
    
Rogelio

Mime
View raw message