Return-Path: Delivered-To: apmail-db-torque-dev-archive@www.apache.org Received: (qmail 78070 invoked from network); 6 May 2004 17:34:06 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 6 May 2004 17:34:06 -0000 Received: (qmail 66294 invoked by uid 500); 6 May 2004 17:34:00 -0000 Delivered-To: apmail-db-torque-dev-archive@db.apache.org Received: (qmail 66285 invoked by uid 500); 6 May 2004 17:34:00 -0000 Mailing-List: contact torque-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Apache Torque Developers List" Reply-To: "Apache Torque Developers List" Delivered-To: mailing list torque-dev@db.apache.org Received: (qmail 66260 invoked from network); 6 May 2004 17:33:59 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 6 May 2004 17:33:59 -0000 Received: (qmail 78057 invoked from network); 6 May 2004 17:34:04 -0000 Received: from localhost.hyperreal.org (HELO minotaur.apache.org) (127.0.0.1) by localhost.hyperreal.org with SMTP; 6 May 2004 17:34:04 -0000 Content-Type: text/plain; charset="iso-8859-1" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: torque-dev@db.apache.org To: torque-dev@db.apache.org Subject: =?iso-8859-1?q?=5BDB_Torque_Wiki=5D_Updated=3A__FrequentlyAskedQuestions?= Date: Thu, 06 May 2004 17:34:04 -0000 Message-ID: <20040506173404.77983.55888@minotaur.apache.org> X-Spam-Rating: localhost.hyperreal.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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, her= e is the short howto! * Torque.properties: -{{{ torque.database.default.adapter=3Dmssql = - torque.dsfactory.default.factory=3Dorg.apache.torque.dsfactory.JndiDataSo= urceFactory = +{{{ torque.database.default.adapter=3Dmssql + torque.dsfactory.default.factory=3Dorg.apache.torque.dsfactory.JndiDataSo= urceFactory torque.dsfactory.default.jndi.path=3Djava:comp/env/jdbc/fortius }}} * web.xml (In the right order according to the servlet spec): -{{{ = - = - = - 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. = - = - = - jdbc/fortius = - = - = - org.apache.torque.pool.TorqueClassicDataSource = - = - = - Container = - = +{{{ + + + 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. + + + jdbc/fortius + + + org.apache.torque.pool.TorqueClassicDataSource + + + Container + }}} = * server.xml (inside your Context): {{{ - = - = - = - validationQuery>/name> = - SELECT 1>/value> = - = - = - maxWait>/name> = - 5000>/value> = - = - = - maxActive>/name> = - 4>/value> = - = - = - password>/name> = - mypassword;/value> = - = - = - url>/name> = - jdbc:microsoft:sqlserver://cuzco:1433;DatabaseName=3Dfortius;Se= lectMethod=3Dcursor>/value> = - = - = - driverClassName>/name> = - com.microsoft.jdbc.sqlserver.SQLServerDriver>/value> = - = - = - maxIdle>/name> = - 2>/value> = - = - = - username>/name> = - SilverUserLogin>/value> = - = + + + + validationQuery>/name> + SELECT 1>/value> + + + maxWait>/name> + 5000>/value> + + + maxActive>/name> + 4>/value> + + + password>/name> + mypassword;/value> + + + url>/name> + jdbc:microsoft:sqlserver://cuzco:1433;DatabaseName=3Dfortius;Se= lectMethod=3Dcursor>/value> + + + driverClassName>/name> + com.microsoft.jdbc.sqlserver.SQLServerDriver>/value> + + + maxIdle>/name> + 2>/value> + + + username>/name> + SilverUserLogin>/value> + }}} * 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 crea= te the datasource. I wrote a little action called DB.java that I could cal= l from torque with a single action: = -{{{ public void doPerform(RunData data, Context context) = - throws Exception { = - try { = - - Log.debug("DB.doPerform called"); = - String foo =3D ''''''; = - javax.naming.Context initCtx =3D new InitialContext(); = - javax.naming.Context envCtx =3D (javax.naming.Context) initCtx= .lookup("java:comp/env"); = - DataSource ds =3D = - (DataSource) envCtx.lookup("jdbc/fortius"); = - if (ds !=3D null) { = - Connection conn =3D ds.getConnection(); = - if (conn !=3D null) { = - System.out.println("Got Connection " + conn.toString()= ); = - Statement stmt =3D conn.createStatement(); = - ResultSet rst =3D = - stmt.executeQuery( = - "select * from kinase"); = - if (rst.next()) { = - foo =3D 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 =3D ''''''; + javax.naming.Context initCtx =3D new InitialContext(); + javax.naming.Context envCtx =3D (javax.naming.Context) initCtx= .lookup("java:comp/env"); + DataSource ds =3D + (DataSource) envCtx.lookup("jdbc/fortius"); + if (ds !=3D null) { + Connection conn =3D ds.getConnection(); + if (conn !=3D null) { + System.out.println("Got Connection " + conn.toString()= ); + Statement stmt =3D conn.createStatement(); + ResultSet rst =3D + stmt.executeQuery( + "select * from kinase"); + if (rst.next()) { + foo =3D rst.getString(2); + System.out.println("foo:" + foo); + } + + conn.close(); + } + } + + } + catch (Exception e) { + Log.error(e); + throw e; + } } }}} = --- EricPugh = +-- EricPugh = =3D=3D How can I execute a stored procedure =3D=3D = '''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 =3D "exec myStroedProc 4, 'hello'"; = - List records =3D WorkorderPeer.executeQuery(SQL); = + String SQL =3D "exec myStroedProc 4, 'hello'"; + List records =3D WorkorderPeer.executeQuery(SQL); = - Vector kinaseATPConcs =3D new Vector(); = - for (Iterator i =3D records.iterator(); i.hasNext();) { = - Record record =3D (Record) i.next(); = - ["KinaseATPConc"] kinaseATPConc =3D new ["KinaseATPConc"](); = - kinaseATPConc.setKinaseId(record.getValue("kinase_id").asString()); = - kinaseATPConc.setAtpConc(record.getValue("atp_conc").asDouble()); = + Vector kinaseATPConcs =3D new Vector(); + for (Iterator i =3D records.iterator(); i.hasNext();) { + Record record =3D (Record) i.next(); + ["KinaseATPConc"] kinaseATPConc =3D 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 comple= x sql query: -{{{String SQL =3D "select top 50 distinct kinase_id,atp_conc from reaction= where workorder_id =3D " = - + workorder.getWorkorderId() = - + " and reaction.result is null and reaction.daughterboard_id is null"= ); = +{{{String SQL =3D "select top 50 distinct kinase_id,atp_conc from reaction= where workorder_id =3D " + + workorder.getWorkorderId() + + " and reaction.result is null and reaction.daughterboard_id is null"= ); }}} = -- EricPugh - = + =3D=3D How to add !P6Spy for printing SQL =3D=3D = '''Answer:''' = 1. add the p6spy.jar to your application classpath - 1. copy the "spy.properties" into your classpath (e.g. same location as l= og4j.properties) = - 1. set the "realdriver" in spy.properties, e.g. realdriver=3Doracle.jdbc.= driver.OracleDriver for Oracle = - 1. change the Torque.properties, e.g. "torque.dsfactory.XXX.connection.dr= iver =3D 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 l= og4j.properties) + 1. set the "realdriver" in spy.properties, e.g. realdriver=3Doracle.jdbc.= driver.OracleDriver for Oracle + 1. change the Torque.properties, e.g. "torque.dsfactory.XXX.connection.dr= iver =3D 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 co= mmon torque tasks and plus this you will be able to run pomre specific task= s configurations as well. = +After successfull instalation of the plugin you will be able to run the co= mmon torque tasks and plus this you will be able to run pomre specific task= s 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 wil= l be in a relative folder, (according to: plugin.properties in your MAVEN_H= OME/plugins/maven-torque-plugin directory) @@ -206,7 +206,7 @@ } else if (CONV_METHOD_UNDERSCORE_IGNORE_DOTS.equals(method)) { javaName =3D underscoreIgnoreDotsMethod(schemaName); = -4) rebuilt the torque-generator maven plugin (src/generator$ maven jar:ins= tall) = +4) rebuilt the torque-generator maven plugin (src/generator$ maven jar:ins= tall) = 5) now I can use the attribute value in the database tags of my schemas = @@ -250,7 +250,7 @@ = =3D=3D How can I count datasets in a table ? =3D=3D = -Suppose one wants to execute a SQL-statement like "select count(*) from em= ployee where name=3D'james'". = +Suppose one wants to execute a SQL-statement like "select count(*) from em= ployee where name=3D'james'". = '''Answer:''' This query can be executed using the following code (assumin= g 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. = =3D=3D Why are large BLOBs and CLOBs not working in Oracle? How do I store= BLOBs or CLOBs > 4000 (or sometimes 2000) bytes? =3D=3D = The problem is with the Oracle JDBC Driver. It doesn't follow the JDBC sta= ndards properly. To fix the problem, use the patched version of Village ava= ilable [http://sweb.uky.edu/~skkann2/village/index.html here] = -- Sarav + +=3D=3D Why is there a problem with Torque runtime properties? =3D=3D + +Some of the properties have been renamed, so the torque properties file is= partly outdated, e.g. +{{{ +#torque.defaults.pool.connectionWaitTimeout =3D 10 +#has been renamed to: +torque.defaults.pool.maxWait=3D10 +}}} +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