I came across a situation where there is the excellent DB schema available, but no torque schema to generate the Peer and Maper classes. Solution>
Setup an eclipse JAVA project.
create a lib folder add all the torque lib and generator jars from lib folder of
each projects. Now we need a build.properties and torque-build.xml. We can get both
of them from the generator project. Now setup the build.properties to point to your
existing database. point the database name, username password and connection
url and don't forget to place the db driver on the lib folder.
Run the torque-build.xml ant script when the ant generator dialogue
comes select the jdbc option unselect the main task.
Make sure to point the place where the generated schema.xml should be put.
This can be specified on the build.properties.
example builld.properties.
-------------------------
torque.project = starcraft
torque.schema.dir=.
application.root = .
torque.database.name = konakart
torque.database.type = mysql
torque.database.user = starcraft
torque.database.password = star
torque.database.driver = com.mysql.jdbc.Driver
torque.database.url = jdbc:mysql://142.148.1.142:3306/starcraft
torque.database.validationQuery = SELECT 1
torque.sameJavaName = false
This will dump a torque schema.xml on the root of the project directory.
How to Run the torque Schema.xml to generate Java classes.
Modify the schema.xml to your database name here ( starcraft-schema.xml) and
inside the schema check the database name is correct and all the can be wrong
if you have not specified the database property in the build.properties.
Now fire the Ant this time select the task OM. This should generate the java classes.
You may need to readjust the packages of the generated classes if the package is
not properly specified on the build.properties.
If any time ant complaints about torquexxx task not found make sure all jars
assosiated to the task in the lib folder of the project. Use your Ctrl+ALT+T
key for search the task on the eclipse project space.
0 Comments:
Post a Comment