martin
James Wang wrote:
0)download torque-3.0.zip ,and decompress it to d:\>torque3.0
1)define the d:\>torque3.0\schema\project-schema.xml note: the table'idMethod="native" and column's autoIncrement="true"
<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> <!DOCTYPE database SYSTEM "http://jakarta.apache.org/turbine/dtd/database.dtd">
<database name="jetspeed">
<table name="USER" idMethod="native">
<column name="USER_ID" required="true"
primaryKey="true" autoIncrement="true"
type="INTEGER"/>
<column name="USER_NAME" type="VARCHAR"
size="225"/> <column name="CREATEDTIME" type="TIMESTAMP"/>
</table>
</database>
2)d:\>torque3.0\ant -f build-torque.xml 3)write a Test.java,insert the following code,put the file into d:\torque3.0\src\java,
Torque.init("Torque.properties");
/* * Creating new objects. These will be inserted * into your database automatically when the * save method is called. */ User us = new User(); us.setUserId(111111111); //this line will not take effect for idmethod='native' us.setUserName("james"); java.util.Date d = new java.sql.Timestamp(System.currentTimeMillis()); us.setCreatedtime(new java.sql.Timestamp(System.currentTimeMillis())); us.save();
4)download the torque-3.0-src.zip and decompress it to d:\>torque-3.0-src download jakarta-ant-1.5,connect to Internet
5)modify D:\torque-3.0-src\torque-3.0\src\java\org\apache\torque\adapter\DBDB2App.java modify the following method,
public String getIDMethodType() { return AUTO_INCREMENT; }
public String getIDMethodSQL(Object obj) { String sql = "VALUES (IDENTITY_VAL_LOCAL())"; //or you can write "VALUES 11","VALUES 123455667","VALUES 755545"........ //just write a function to get a value and let the DB2 to execute. return sql; }
6)build torque source,and get the
D:\torque-3.0-src\torque-3.0\target\torque-3.0.jar
D:\torque-3.0-src\torque-3.0\ant -jar
7)replace D:\torque3.0\lib\torque-3.0.jar with this
8)set classpath including the all jars within the
directory D:\torque3.0\lib\ 9)java Test
OK!!!!!everything is OK!that's all my night work
__________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
