db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From torque-...@db.apache.org
Subject [DB Torque Wiki] Updated: FrequentlyAskedQuestions
Date Thu, 06 May 2004 17:34:04 GMT
   Date: 2004-05-06T10:34:03
   Editor: 213.78.116.250 <>
   Wiki: DB Torque Wiki
   Page: FrequentlyAskedQuestions
   URL: http://wiki.apache.org/db-torque/FrequentlyAskedQuestions

   no comment

Change Log:

------------------------------------------------------------------------------
@@ -12,142 +12,142 @@
 
 '''Answer:''' Read the Torque Howto for indepth information.  However, here is the short
howto!
  *  Torque.properties:
-{{{ torque.database.default.adapter=mssql 
- torque.dsfactory.default.factory=org.apache.torque.dsfactory.JndiDataSourceFactory 
+{{{ torque.database.default.adapter=mssql
+ torque.dsfactory.default.factory=org.apache.torque.dsfactory.JndiDataSourceFactory
  torque.dsfactory.default.jndi.path=java:comp/env/jdbc/fortius }}}
  *  web.xml (In the right order according to the servlet spec):
-{{{ 
-<resource-ref> 
-  <description> 
-    Resource reference to a factory for java.sql.Connection 
-    instances that may be used for talking to a particular 
-    database that is configured in the server.xml file. 
-  </description> 
-  <res-ref-name> 
-    jdbc/fortius 
-  </res-ref-name> 
-  <res-type> 
-    org.apache.torque.pool.TorqueClassicDataSource 
-  </res-type> 
-  <res-auth> 
-    Container 
-  </res-auth> 
+{{{
+<resource-ref>
+  <description>
+    Resource reference to a factory for java.sql.Connection
+    instances that may be used for talking to a particular
+    database that is configured in the server.xml file.
+  </description>
+  <res-ref-name>
+    jdbc/fortius
+  </res-ref-name>
+  <res-type>
+    org.apache.torque.pool.TorqueClassicDataSource
+  </res-type>
+  <res-auth>
+    Container
+  </res-auth>
  </resource-ref>
 }}}
 
  *  server.xml (inside your Context):
 {{{
- <Resource name="jdbc/fortius" scope="Shareable" type="javax.sql.DataSource"/> 
- <ResourceParams name="jdbc/fortius"> 
-  <parameter> 
-    <name>validationQuery>/name> 
-    <value>SELECT 1>/value> 
-  </parameter> 
-  <parameter> 
-    <name>maxWait>/name> 
-    <value>5000>/value> 
-  </parameter> 
-  <parameter> 
-    <name>maxActive>/name> 
-    <value>4>/value> 
-  </parameter> 
-  <parameter> 
-    <name>password>/name> 
-    <value>mypassword;/value> 
-  </parameter> 
-  <parameter> 
-    <name>url>/name> 
-    <value>jdbc:microsoft:sqlserver://cuzco:1433;DatabaseName=fortius;SelectMethod=cursor>/value>

-  </parameter> 
-  <parameter> 
-    <name>driverClassName>/name> 
-    <value>com.microsoft.jdbc.sqlserver.SQLServerDriver>/value> 
-  </parameter> 
-  <parameter> 
-    <name>maxIdle>/name> 
-    <value>2>/value> 
-  </parameter> 
-  <parameter> 
-    <name>username>/name> 
-    <value>SilverUserLogin>/value> 
-  </parameter> 
+ <Resource name="jdbc/fortius" scope="Shareable" type="javax.sql.DataSource"/>
+ <ResourceParams name="jdbc/fortius">
+  <parameter>
+    <name>validationQuery>/name>
+    <value>SELECT 1>/value>
+  </parameter>
+  <parameter>
+    <name>maxWait>/name>
+    <value>5000>/value>
+  </parameter>
+  <parameter>
+    <name>maxActive>/name>
+    <value>4>/value>
+  </parameter>
+  <parameter>
+    <name>password>/name>
+    <value>mypassword;/value>
+  </parameter>
+  <parameter>
+    <name>url>/name>
+    <value>jdbc:microsoft:sqlserver://cuzco:1433;DatabaseName=fortius;SelectMethod=cursor>/value>
+  </parameter>
+  <parameter>
+    <name>driverClassName>/name>
+    <value>com.microsoft.jdbc.sqlserver.SQLServerDriver>/value>
+  </parameter>
+  <parameter>
+    <name>maxIdle>/name>
+    <value>2>/value>
+  </parameter>
+  <parameter>
+    <name>username>/name>
+    <value>SilverUserLogin>/value>
+  </parameter>
  </ResourceParams> }}}
  *  Libraries.  Make sure you put your Jar's that are need for the driver where they can
be reached.  For Tomcat, put them in $(CATALINA_HOME)/common/lib, otherwise Tomcat can not
create the connection.
  *  Debugging
 If all else fails, first try and verify that you are able to directly create the datasource.
 I wrote a little action called DB.java that I could call from torque with a single action:
 
-{{{    public void doPerform(RunData data, Context context) 
-        throws Exception { 
-        try { 
-
-            Log.debug("DB.doPerform called"); 
-            String foo = ''''''; 
-            javax.naming.Context initCtx = new InitialContext(); 
-            javax.naming.Context envCtx = (javax.naming.Context) initCtx.lookup("java:comp/env");

-            DataSource ds = 
-                    (DataSource) envCtx.lookup("jdbc/fortius"); 
-            if (ds != null) { 
-                Connection conn = ds.getConnection(); 
-                if (conn != null) { 
-                    System.out.println("Got Connection " + conn.toString()); 
-                    Statement stmt = conn.createStatement(); 
-                    ResultSet rst = 
-                            stmt.executeQuery( 
-                            "select * from kinase"); 
-                    if (rst.next()) { 
-                        foo = rst.getString(2); 
-                        System.out.println("foo:" + foo); 
-                    } 
-
-                    conn.close(); 
-                } 
-            } 
-
-        } 
-        catch (Exception e) { 
-            Log.error(e); 
-            throw e; 
-        } 
+{{{    public void doPerform(RunData data, Context context)
+        throws Exception {
+        try {
+
+            Log.debug("DB.doPerform called");
+            String foo = '''''';
+            javax.naming.Context initCtx = new InitialContext();
+            javax.naming.Context envCtx = (javax.naming.Context) initCtx.lookup("java:comp/env");
+            DataSource ds =
+                    (DataSource) envCtx.lookup("jdbc/fortius");
+            if (ds != null) {
+                Connection conn = ds.getConnection();
+                if (conn != null) {
+                    System.out.println("Got Connection " + conn.toString());
+                    Statement stmt = conn.createStatement();
+                    ResultSet rst =
+                            stmt.executeQuery(
+                            "select * from kinase");
+                    if (rst.next()) {
+                        foo = rst.getString(2);
+                        System.out.println("foo:" + foo);
+                    }
+
+                    conn.close();
+                }
+            }
+
+        }
+        catch (Exception e) {
+            Log.error(e);
+            throw e;
+        }
     } }}}
 
--- EricPugh 
+-- EricPugh
 
 == How can I execute a stored procedure ==
 
 '''Answer:''' You can use some of the functionality exposed by the Village library to execute
and deal with the result set of your stored procedure:
 
-{{{  import com.workingdogs.village.Record; 
+{{{  import com.workingdogs.village.Record;
 
-  String SQL = "exec myStroedProc 4, 'hello'"; 
-  List records = WorkorderPeer.executeQuery(SQL); 
+  String SQL = "exec myStroedProc 4, 'hello'";
+  List records = WorkorderPeer.executeQuery(SQL);
 
-  Vector kinaseATPConcs = new Vector(); 
-  for (Iterator i = records.iterator(); i.hasNext();) { 
-    Record record = (Record) i.next(); 
-    ["KinaseATPConc"] kinaseATPConc = new ["KinaseATPConc"](); 
-    kinaseATPConc.setKinaseId(record.getValue("kinase_id").asString()); 
-    kinaseATPConc.setAtpConc(record.getValue("atp_conc").asDouble()); 
+  Vector kinaseATPConcs = new Vector();
+  for (Iterator i = records.iterator(); i.hasNext();) {
+    Record record = (Record) i.next();
+    ["KinaseATPConc"] kinaseATPConc = new ["KinaseATPConc"]();
+    kinaseATPConc.setKinaseId(record.getValue("kinase_id").asString());
+    kinaseATPConc.setAtpConc(record.getValue("atp_conc").asDouble());
 
-    kinaseATPConcs.add(kinaseATPConc); 
+    kinaseATPConcs.add(kinaseATPConc);
   } }}}
 
 What else you may notice is that if you do something similar with a complex sql query:
-{{{String SQL = "select top 50 distinct kinase_id,atp_conc from reaction where workorder_id
= " 
-    + workorder.getWorkorderId() 
-    + " and reaction.result is null and reaction.daughterboard_id is null"); 
+{{{String SQL = "select top 50 distinct kinase_id,atp_conc from reaction where workorder_id
= "
+    + workorder.getWorkorderId()
+    + " and reaction.result is null and reaction.daughterboard_id is null");
 }}}
 
 -- EricPugh
-				
+
 == How to add !P6Spy for printing SQL ==
 
 '''Answer:'''
 
  1. add the p6spy.jar to your application classpath
- 1. copy the "spy.properties" into your classpath (e.g. same location as log4j.properties)

- 1. set the "realdriver" in spy.properties, e.g. realdriver=oracle.jdbc.driver.OracleDriver
for Oracle 
- 1. change the Torque.properties, e.g. "torque.dsfactory.XXX.connection.driver = com.p6spy.engine.spy.P6SpyDriver"
to use the proxy JDBC drivers 
- 1. run your application 
+ 1. copy the "spy.properties" into your classpath (e.g. same location as log4j.properties)
+ 1. set the "realdriver" in spy.properties, e.g. realdriver=oracle.jdbc.driver.OracleDriver
for Oracle
+ 1. change the Torque.properties, e.g. "torque.dsfactory.XXX.connection.driver = com.p6spy.engine.spy.P6SpyDriver"
to use the proxy JDBC drivers
+ 1. run your application
  1. !P6Spy creates a spy.log in your current directory
 
 -- Siegfried Goeschl
@@ -164,7 +164,7 @@
 http://db.apache.org/torque/maven-plugin/
 http://db.apache.org/torque/maven-howto.html
 
-After successfull instalation of the plugin you will be able to run the common torque tasks
and plus this you will be able to run pomre specific tasks configurations as well. 
+After successfull instalation of the plugin you will be able to run the common torque tasks
and plus this you will be able to run pomre specific tasks configurations as well.
 For example the command line:
 maven -D absolute_folder_location torque:om
 which will look inside the given path and will run torque's task OM using the build.properties
that are located there. and the xml defined schema will be in a relative folder, (according
to: plugin.properties in your MAVEN_HOME/plugins/maven-torque-plugin directory)
@@ -206,7 +206,7 @@
 		} else if (CONV_METHOD_UNDERSCORE_IGNORE_DOTS.equals(method)) {
 			javaName = underscoreIgnoreDotsMethod(schemaName);
 
-4) rebuilt the torque-generator maven plugin (src/generator$ maven jar:install) 
+4) rebuilt the torque-generator maven plugin (src/generator$ maven jar:install)
 
 5) now I can use the attribute value in the database tags of my schemas
 
@@ -250,7 +250,7 @@
 
 == How can I count datasets in a table ? ==
 
-Suppose one wants to execute a SQL-statement like "select count(*) from employee where name='james'".

+Suppose one wants to execute a SQL-statement like "select count(*) from employee where name='james'".
 
 '''Answer:''' This query can be executed using the following code (assuming the employee
Table has at least two Columns: "NAME" and "ID", where ID is the primary key, and the Peer
class to the employee Table is EmployeePeer (sorry the link does not work but I don't know
how to get rid of it)):
 {{{
@@ -276,10 +276,20 @@
 
 There is a log4j.properties file inside the torque-gen-3.1 jar file in the lib/ directory,
and the properties from there are being used instead.
 
-Solution: Remove the torque-gen-3.1 jar file after compiling the example.  The file is not
needed for running the app. 
+Solution: Remove the torque-gen-3.1 jar file after compiling the example.  The file is not
needed for running the app.
 
 == Why are large BLOBs and CLOBs not working in Oracle? How do I store BLOBs or CLOBs >
4000 (or sometimes 2000) bytes? ==
 
 The problem is with the Oracle JDBC Driver. It doesn't follow the JDBC standards properly.
To fix the problem, use the patched version of Village available [http://sweb.uky.edu/~skkann2/village/index.html
here]
 
 -- Sarav
+
+== Why is there a problem with Torque runtime properties? ==
+
+Some of the properties have been renamed, so the torque properties file is partly outdated,
e.g.
+{{{
+#torque.defaults.pool.connectionWaitTimeout = 10
+#has been renamed to:
+torque.defaults.pool.maxWait=10
+}}}
+Read the Jakarta Commons DBCP docs about DBCP configuration and adapt your torque properties
file accordingly.

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message