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 to...@db.apache.org on 2005/02/04 21:20:21 UTC
[DB Torque Wiki] Updated: GettingTorqueToWork
Date: 2005-02-04T12:20:21
Editor: BrettSutton
Wiki: DB Torque Wiki
Page: GettingTorqueToWork
URL: http://wiki.apache.org/db-torque/GettingTorqueToWork
no comment
Change Log:
------------------------------------------------------------------------------
@@ -238,5 +238,93 @@
-- Siegfried Goeschl
+----
+= Maven, Torque and the torque:jdbc goal =
+If have spent some time trying to get maven to work with torque:jdbc and there seems to be little doco on either (at least for a complete maven and torque novice). So here are the steps I used to get it working with Microsoft SQLServer.
+
+ 1. Install an appropriate Java SDK
+ 2. Add the Java SDK bin directory to your path variable so that you can type 'java' at the command prompt and it successfully starts.
+ 3. Install Maven
+ 4. Add the Maven bin directory to your path variable so that you can type 'maven' at the command prompt and it successfully starts.
+ 5. Use Maven to install the torque plugin as follows: (check the [Maven-howto for the latest details on this|http://db.apache.org/torque/maven-howto.html])
+ maven plugin:download -DartifactId=maven-torque-plugin -DgroupId=torque -Dversion=3.1.1
+ 6. Create yourself a project directory (this can be anywhere you like).
+ 7. In your project directory create a project.properties file as follows:
+
+{{{
+# -------------------------------------------------------------------
+#
+# T O R Q U E S E T T I N G S
+#
+# -------------------------------------------------------------------
+
+torque.project = MyDatabase
+torque.database = mssql
+
+torque.database.createUrl = jdbc:microsoft:sqlserver://localhost:1433
+torque.database.buildUrl = jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=MyDatabase
+torque.database.url = jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=MyDatabase
+torque.database.driver = com.microsoft.jdbc.sqlserver.SQLServerDriver
+torque.database.user = dbusername
+torque.database.password = dbpassword
+torque.database.host = localhost
+torque.database.schema = %
+}}}
+'''Note''' the schema setting may be different for different database types as a hint the following java call is made to return tables
+{{{
+tableNames = conn.getMetaData().getTables(null, schema, "%", types);
+}}}
+Where schema is taken from the torque.database.schema settings in the project.properties files.
+If when you get to the generation step and it appears to works but you have a schema.xml file which contains no tables then its probably because the schema setting is wrong.
+
+ 8.#8 create a src directory under your project directory
+ 9. create a schema directory under the src directory you just created.
+ 9. Obtain the jars for your chosen databases' jdbc library. e.g. for SQL Server you need msutil.jar, msbase.jar and mssqlserver.jar
+ 10. I had a real problem injecting these jars into the classpath, all of the normal techniques don't work with maven. I have found some doc which says to add the jars to the torque project.xml dependancies but I was unable to get this method to work and as soon as you update (re-install) the torque plugin you loose your dependancies. So the hack I came up with is to copy the database jdbc jars into the maven install. Under the maven installation directory (as of maven 1.0.2) you will find a lib\endorsed directory. Just copy your database jars into there and all will be well.
+ 11. run maven torque:jdbc at the command prompt making sure that your current working directory is your project directory.
+ 12. You should seem something similar to :
+{{{
+C:\dev\torque>maven torque:jdbc
+ __ __
+| \/ |__ _Apache__ ___
+| |\/| / _` \ V / -_) ' \ ~ intelligent projects ~
+|_| |_\__,_|\_/\___|_||_| v. 1.0.2
+
+build:start:
+
+torque:init:
+
+torque:jdbc:
+ [torque-jdbc-transform] Torque - JDBCToXMLSchema starting
+ [torque-jdbc-transform] Your DB settings are:
+ [torque-jdbc-transform] driver : com.microsoft.jdbc.sqlserver.SQLServerDriver
+ [torque-jdbc-transform] URL : jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=MyDatabase
+ [torque-jdbc-transform] user : dbusername
+ [torque-jdbc-transform] schema : %
+ [torque-jdbc-transform] DB driver sucessfuly instantiated
+ [torque-jdbc-transform] DB connection established
+ [torque-jdbc-transform] Getting table list...
+ [torque-jdbc-transform] Building column/table map...
+ [torque-jdbc-transform] Processing table: dtproperties
+
+... you should see each table and view in your database listed here ...
+
+ [torque-jdbc-transform] Processing table: tblAccount
+ [torque-jdbc-transform] Processing table: tblAllocation
+ [torque-jdbc-transform] Processing table: vwWatchList
+ [torque-jdbc-transform] C:\dev\torque/src/schema/schema.xml
+ [torque-jdbc-transform] Torque - JDBCToXMLSchema finished
+BUILD SUCCESSFUL
+Total time: 16 seconds
+Finished at: Sat Feb 05 06:47:00 EST 2005
+}}}
+
+ 13.#13 At the end of the above process you torque should have created a schema.xml under your project directory src/schema/
+ 14. Check the schema.xml actually contains your databases tables. If not check the torque.database.schema setting in your project.properties file.
+
+Hope this helps.
+BrettSutton
+
+
-----
a great hands on tutorial at http://users.volja.net/amanita1/
---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org