Re: No DataSourceFactory configured

2008-02-07 Thread Guy Galil
Do you call Torque.init() in your code before any attempt to use the
connection?

On Wed, 2008-02-06 at 17:50 -0800, Owen B. Mehegan wrote:
> Hi, I've seen this question asked many times in the mailing list 
> archives, but so far I can't figure out a solution to the problem in my 
> case. I have a unit test that is using Easymock to create mock database 
> objects to test against. When I run the test, it always fails with this 
> error:
> 
> java.lang.NullPointerException: There was no DataSourceFactory 
> configured for the connection recoverable
> 
> But my Torque.properties _does_ include a datasource called 'recoverable:'
> 
> torque.dsfactory.recoverable.factory=com.friend.db.RecoverableDataSourceFactory
> torque.dsfactory.recoverable.pool.maxActive=1
> torque.dsfactory.recoverable.pool.maxIdle=1
> torque.dsfactory.recoverable.pool.maxWait=1000
> torque.dsfactory.recoverable.pool.testOnBorrow=false
> torque.dsfactory.recoverable.pool.validationQuery=SELECT 1
> torque.dsfactory.recoverable.connection.driver=com.mockrunner.mock.jdbc.MockDriver
> torque.dsfactory.recoverable.connection.url = java://foo
> torque.dsfactory.recoverable.connection.user = user
> torque.dsfactory.recoverable.connection.password = foo
> 
> This entry is similar to others in the torque.properties, so I don't 
> think the syntax is incorrect. What else could I be doing wrong?
> 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Configure torque for struts

2007-12-16 Thread Guy Galil
You need to initialize Torque only once at the beginning of your
application, We do it in the init() method of the first servlet we load
On Mon, 2007-12-17 at 08:17 +0530, Ram wrote:
> Well to be specific, I have configured the torque, generated the sql schema
> files and made it to run perfectly. I even tested using it inside  a main
> class like this.
> 
>  public static void main(String[] args) throws Exception
> {
> String path = "../crm/Torque.properties";
> 
> Torque.init(path);
> Contacts contacts = new Contacts();
> contacts.setFirstname("Ramesh");
> contacts.setLastname("R");
> contacts.setMiddlename("n");
> contacts.save();
> }
> 
> But my purpose is to use it in struts. I am using it like this.
> 
> public ActionForward execute(ActionMapping mapping, ActionForm form,
> HttpServletRequest request, HttpServletResponse response)
> throws Exception
> {
> String path = "../crm/Torque.properties";
> 
> Torque.init(path);
> Contacts contacts = new Contacts();
> contacts.setFirstname("xyz");
> contacts.setLastname("s");
> contacts.setMiddlename("n");
> contacts.save();
> request.setAttribute("Id", contacts.getPrimaryKey());
> return mapping.findForward("success");
> }
> Please guide whether am on a right track.
> 
> On Dec 17, 2007 7:54 AM, Alvaro Coronel <[EMAIL PROTECTED]> wrote:
> 
> > Hi Ramesh. If you can be more specific, it will be a lot easier to help
> > you. Tell us what you are trying to do, how you are trying and how it fails.
> >
> > Best regards,
> > Álvaro.
> >
> >
> >
> > Ramesh R <[EMAIL PROTECTED]> wrote: Hi,
> >
> >
> >
> > I am using torque for struts application. I am currently finding difficult
> > configuring torque. Please guide me in how to do this.
> >
> >
> >
> >
> >
> > Thanks
> >
> >
> >
> > Ramesh r
> >
> >
> >
> >
> >
> >
> > -
> > Looking for last minute shopping deals?  Find them fast with Yahoo!
> > Search.
> >
> 
> 
> 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: encrypt database user info in the Torque.properties?

2007-05-24 Thread Guy Galil
It is definitely a legitimate concern.
At the least the password should not be stored in plain text.
What I do instead of calling Torque.init();
is create the import org.apache.commons.configuration.Configuration
object:
 Configuration c = new PropertiesConfiguration(configFile);
 then manipulate the Configuration object to modify the password in it
and then initialize Torque with the Configuration object.

Cheers Guy

  On Thu, 2007-05-24 at 17:00 -0500, jill han wrote:
> I put database user login data in the Torque.properties as  
> 
> torque.dsfactory.default.connection.user = username
> torque.dsfactory.default.connection.password = userpassword
> 
> At first, I think it is quite common practice. Now somebody questioned
> it for the security reason, saying
> "Storage of user information in plain text will allow the database
> to be compromised if web/app server is hacked."
> It was suggested to Encrypt the database details in the configuration
> file.
> 
> Do you think it is a legitimate concern?
> Do you encrypt such data in the configuration file?
> 
> Your input is appreciated as always.
> 
> Jill
> 
> 
> 
> -
> 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]



Re: RetrievByPK strange behavior - a Torque bug

2007-02-28 Thread Guy Galil
Although nobody responded to my post I guess this bug still exists in
Torque.
The problem is the way org.apache.torque.om.NumberKey instantiates a
BigDecimal for a long key - see Sun's description of the reasons for
this behavior - not a bug in their view :
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4114020

I fixed NumberKey.java by replacing:
  public NumberKey(long key)
{
this.key = new BigDecimal(key);
}

With:
  public NumberKey(long key)
{
this.key = BigDecimal.valueOf(key);
} 

as recommended in the above Sun link.
To test this you can use:
public static void main(String[] args) 
{
long pk = Long.parseLong("226200031");
SimpleKey sk = SimpleKey.keyFor(pk);
System.out.print(sk.getValue());
}

Cheers Guy

On Wed, 2007-02-21 at 15:30 -0500, Guy Galil wrote:
> We are using an old version of Torque - Torque 3.0.2 for a long time
> now.
> We recently encountered a strange behavior of the retrieveByPK method:
> we have a column defined as -
> 
>name="MYTABLE_LOG_ID" 
>   required="true" 
>   primaryKey="true" 
>   type="BIGINT" 
>   autoIncrement="true"/>
> 
> 
> 
> 
> 
> 
> The generated sql is -
> drop table if exists MYTABLE_LOG;
> 
> CREATE TABLE MYTABLE_LOG
> (
> MYTABLE_LOG_ID BIGINT NOT NULL AUTO_INCREMENT,
> 
> 
> the mysql table is actually created with the column type
>  bigint(20)
> 
> Id values in the database get to be big.
> 
> The problem is when using retrievebypk and the id passed is long. The
> method in the base class looks like:
> public static MytableLog retrieveByPK(long pk)
> throws TorqueException
> {
> return retrieveByPK(SimpleKey.keyFor(pk));
> }
> 
> looking at the values in a debugger we see:
> pk = 226200031
> SimpleKey.keyFor(pk) = 226200032
> and
> return retrieveByPK(SimpleKey.keyFor(pk)) either fails fails (failed to
> retrieve one
> row...) if the record is not found or returns the wrong record (see it
> passes the id + 1)
> 
> This problem did not occur when our keys were of type integer.
> 
> Any help will be appreciated
> Guy
> 
> 
> -
> 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]



RetrievByPK strange behavior

2007-02-21 Thread Guy Galil
We are using an old version of Torque - Torque 3.0.2 for a long time
now.
We recently encountered a strange behavior of the retrieveByPK method:
we have a column defined as -








The generated sql is -
drop table if exists MYTABLE_LOG;

CREATE TABLE MYTABLE_LOG
(
MYTABLE_LOG_ID BIGINT NOT NULL AUTO_INCREMENT,


the mysql table is actually created with the column type
 bigint(20)

Id values in the database get to be big.

The problem is when using retrievebypk and the id passed is long. The
method in the base class looks like:
public static MytableLog retrieveByPK(long pk)
throws TorqueException
{
return retrieveByPK(SimpleKey.keyFor(pk));
}

looking at the values in a debugger we see:
pk = 226200031
SimpleKey.keyFor(pk) = 226200032
and
return retrieveByPK(SimpleKey.keyFor(pk)) either fails fails (failed to
retrieve one
row...) if the record is not found or returns the wrong record (see it
passes the id + 1)

This problem did not occur when our keys were of type integer.

Any help will be appreciated
Guy


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Exception

2007-02-09 Thread Guy Galil
On our linux system it is set in a script called:
/var/guardium/jakarta-tomcat-4.1.30/bin/start_tomcat
otherwise look at Tomcat's documentation
On Thu, 2007-02-08 at 15:52 -0600, jill han wrote:
> Thanks, Would you please let me know which file?
> I looked into the files in Tomcat, just could not figure out which file
> should be related to.
> 
> - Original Message - 
> From: "Guy Galil" <[EMAIL PROTECTED]>
> To: "Apache Torque Users List" 
> Sent: Thursday, February 08, 2007 2:58 PM
> Subject: RE: Exception
> 
> 
> > You build your project using java 6 but trying to run it on a java 5
> or
> > 1.4 jvm - Sun's internal versions are different then the official
> > external version notation - 50.0 is java 6 while 49.0 is java 5.
> > You need to configure you Tomcat to use the newer JVM
> > On Thu, 2007-02-08 at 14:39 -0600, jill han wrote:
> >> >From the log file, the exception is caused by 
> >> **
> >> 2007-02-08 14:29:07,586 [main] ERROR
> >> org.apache.turbine.services.BaseServiceBroker-
> >> org.apache.turbine.services.InitializationException: XMLRPCService
> >> failed to initialize: Failed to instantiate
> >> com.nequalsone.webservice.FormLetter:
> com/nequalsone/om/BaseLibraryItem
> >> (Unsupported major.minor version 50.0)
> >> **
> >> Any helps will be appreciated.
> >> Jill
> >> 
> >> -Original Message-
> >> From: jill han 
> >> Sent: Thursday, February 08, 2007 10:35 AM
> >> To: 'Turbine Users List'
> >> Subject: Exception
> >> 
> >> I have turbine/torque/velocity application. I upgraded java from 4 to
> 6.
> >> I used maven to build the objects.
> >> The build is successful. However after I loaded the classes to
> >> tomcat4.x, it threw a exception as follows. If I changed back to
> java4,
> >> rebuild, load the objects to tomcat, the application will be running
> >> fine. Is there anything else that I need to update? 
> >> Thanks for your helps.
> >> Jill
> >> 
> >> *
> >> HTTP Status 500 - 
> >> 
> >> type Exception report
> >> 
> >> message 
> >> 
> >> description The server encountered an internal error () that
> prevented
> >> it from fulfilling this request.
> >> 
> >> exception 
> >> 
> >> java.lang.NullPointerException
> >> at org.apache.turbine.Turbine.doGet(Turbine.java:876)
> >> at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
> >> at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >> at
> >>
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
> >> tionFilterChain.java:247)
> >> at
> >>
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
> >> erChain.java:193)
> >> at
> >>
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
> >> e.java:256)
> >> at
> >>
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
> >> nvokeNext(StandardPipeline.java:643)
> >> at
> >>
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
> >> 80)
> >> at
> >> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> >> at
> >>
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
> >> e.java:191)
> >> at
> >>
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
> >> nvokeNext(StandardPipeline.java:643)
> >> at
> >>
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
> >> 80)
> >> at
> >> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
> >> at
> >>
> org.apache.catalina.core.StandardContext.invoke(StandardContext.java:241
> >> 6)
> >> at
> >>
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
> >> :180)
> >> at
> >>
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
> >> nvokeNext(StandardPipeline.java:643)
> >> at
> >>
> org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherVa
> >> lve.java:171)
> >> at
> >>
> org.apache.catalina.core.StandardPipeline$Sta

RE: Exception

2007-02-08 Thread Guy Galil
You build your project using java 6 but trying to run it on a java 5 or
1.4 jvm - Sun's internal versions are different then the official
external version notation - 50.0 is java 6 while 49.0 is java 5.
You need to configure you Tomcat to use the newer JVM
On Thu, 2007-02-08 at 14:39 -0600, jill han wrote:
> >From the log file, the exception is caused by 
> **
> 2007-02-08 14:29:07,586 [main] ERROR
> org.apache.turbine.services.BaseServiceBroker-
> org.apache.turbine.services.InitializationException: XMLRPCService
> failed to initialize: Failed to instantiate
> com.nequalsone.webservice.FormLetter: com/nequalsone/om/BaseLibraryItem
> (Unsupported major.minor version 50.0)
> **
> Any helps will be appreciated.
> Jill
> 
> -Original Message-
> From: jill han 
> Sent: Thursday, February 08, 2007 10:35 AM
> To: 'Turbine Users List'
> Subject: Exception
> 
> I have turbine/torque/velocity application. I upgraded java from 4 to 6.
> I used maven to build the objects.
> The build is successful. However after I loaded the classes to
> tomcat4.x, it threw a exception as follows. If I changed back to java4,
> rebuild, load the objects to tomcat, the application will be running
> fine. Is there anything else that I need to update? 
> Thanks for your helps.
> Jill
> 
> *
> HTTP Status 500 - 
> 
> type Exception report
> 
> message 
> 
> description The server encountered an internal error () that prevented
> it from fulfilling this request.
> 
> exception 
> 
> java.lang.NullPointerException
>   at org.apache.turbine.Turbine.doGet(Turbine.java:876)
>   at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
>   at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
>   at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
> tionFilterChain.java:247)
>   at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
> erChain.java:193)
>   at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
> e.java:256)
>   at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
> nvokeNext(StandardPipeline.java:643)
>   at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
> 80)
>   at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
>   at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
> e.java:191)
>   at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
> nvokeNext(StandardPipeline.java:643)
>   at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
> 80)
>   at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
>   at
> org.apache.catalina.core.StandardContext.invoke(StandardContext.java:241
> 6)
>   at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
> :180)
>   at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
> nvokeNext(StandardPipeline.java:643)
>   at
> org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherVa
> lve.java:171)
>   at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
> nvokeNext(StandardPipeline.java:641)
>   at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
> :172)
>   at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
> nvokeNext(StandardPipeline.java:641)
>   at
> org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:577
> )
>   at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
> nvokeNext(StandardPipeline.java:641)
>   at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
> 80)
>   at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
>   at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
> java:174)
>   at
> org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.i
> nvokeNext(StandardPipeline.java:643)
>   at
> org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:4
> 80)
>   at
> org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
>   at
> org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
>   at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:60
> 1)
>   at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processC
> onnection(Http11Protocol.java:392)
>   at
> org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:56
> 5)
>   at
> org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool
> .java:619)
>   at java.lang.Thread.run(Thread.java:536)
> 
> 
> Apache Tomcat/4.1.27
> 
> 
> -

Re: no DataSourceFactory configured

2007-01-22 Thread Guy Galil
Do you initiate Torque in your code?
In the old version we use we call 
Torque.init();
Before we try using Torque in any way.
I put it in the init method of the first servlet of the web application.

On Mon, 2007-01-22 at 11:46 -0600, Pierre-Alain Branger wrote:
> Hi everybody,
> 
> I follow your suggestions but I still can not execute my program properly.
> Following, the different things I did:
> 
> - I added torque.properties, actually it was not in it:
> export CLASSPATH=/home/pbranger/BddPortalCCG/src/conf
> By the way the tutorial don't mention this step.
> 
> - I also added torque.properties to the default source package in Net beans.
> 
> - My database is properly started
> 
> - Connection url, password and username are right in the configuration file.
> I just borrow user and password in the mail I sent.
> Thomas, what do you mean by "I am sure whethet mysql accepts connections
>  without specifying a database user (as you did)"?
> I can connect to mysql by mysql -u user -p but if I don't specify user I
> obviously can not connect.
> 
> Thanks again for your help,
> 
> Pierre
> 
> > This usually means that connecting to the database failed. Possible
> > reasons
> > are
> > - the database is not started
> > - the connection url, password or username are wrong in the configuration
> > file
> > Loking at your configuration, I am sure whethet mysql accepts connections
> > without specifying a database user (as you did)
> >
> >  Thomas
> >
> > "Pierre-Alain Branger" <[EMAIL PROTECTED]> schrieb am 20.01.2007
> > 02:04:11:
> >
> >> Hi everybody,
> >>
> >> I follow the tutorial and could generate my mysql database and the
> >> corresponding java access classes. I made a jar and add it to a java
> >> project that compiled well. But when I launch my application I obtain
> >> the
> >> following message:
> >>
> >> java.lang.NullPointerException: There was no DataSourceFactory
> >> configured
> >> for the connection BddPortalCCG
> >> at
> >> org.apache.torque.TorqueInstance.getConnection(TorqueInstance.java:711)
> >> at org.apache.torque.Torque.getConnection(Torque.java:268)
> >> at
> >> org.apache.torque.util.Transaction.beginOptional(Transaction.java:80)
> >> at org.apache.torque.util.Transaction.begin(Transaction.java:62)
> >> at
> >> mx.unam.ccg.BddPortal.BaseApplication.save(BaseApplication.java:361)
> >> at
> >> mx.unam.ccg.BddPortal.BaseApplication.save(BaseApplication.java:343)
> >> at testbddportalccg.Main.main(Main.java:36)
> >>
> >> I hope soñeone could help, me. Here are the different configuring files
> >> I
> >> use:
> >>
> >> - torque.properties 
> >>
> >> torque.database.default = BddPortalCCG
> >> torque.database.BddPortalCCG.adapter = mysql
> >>
> >> # Using commons-dbcp
> >> torque.dsfactory.BddPortalCCG.factory =
> >> org.apache.torque.dsfactory.SharedPoolDataSourceFactory
> >> torque.dsfactory.BddPortalCCG.connection.driver =
> >> org.gjt.mm.mysql.Driver
> >> torque.dsfactory.BddPortalCCG.connection.url =
> >> jdbc:mysql://localhost:3306/BddPortalCCG
> >> torque.dsfactory.BddPortalCCG.connection.user =
> >> torque.dsfactory.BddPortalCCG.connection.password =
> >>
> >>
> >> - project.properties 
> >> # The name of the project Torque will generate code for.
> >> torque.project=BddPortalCCG
> >>
> >> # The target database platform.
> >> torque.database=mysql
> >>
> >> # The target package to put the generated classes in.
> >> torque.targetPackage=mx.unam.ccg.BddPortal
> >>
> >> # The JDBC URL that Torque can use to create and
> >> # drop databases if instructed to do so.
> >> torque.database.createUrl=jdbc:mysql://localhost/mysql
> >>
> >> # The JDBC URL that will be used to create tables in your database.
> >> torque.database.buildUrl=jdbc:mysql://localhost/BddPortalCCG
> >>
> >> # The JDBC URL that will be used to access your database.
> >> torque.database.url=jdbc:mysql://localhost/BddPortalCCG
> >>
> >> # The JDBC database driver to use when connecting to your database.
> >> torque.database.driver=org.gjt.mm.mysql.Driver
> >>
> >> # The administrative username that has sufficient privileges to create
> >> # and drop databases and tables that Torque executes at generation time.
> >> torque.database.user=
> >>
> >> # The administrative password for the supplied username.
> >> torque.database.password=
> >>
> >> # The hostname or IP address of your database server.
> >> torque.database.host=localhost
> >>
> >> # The location of the your *-schema.xml files (see below).
> >> torque.schema.dir=./schema
> >>
> >>
> >> - schema.xml 
> >> 
> >>  >>  "http://db.apache.org/torque/dtd/database_3_1.dtd";>
> >>
> >>  >>   name="BddPortalCCG">
> >>
> >>   
> >>  >>   name="idApp"
> >>   required="true"
> >>   primaryKey="true"
> >>   type="INTEGER"
> >>   description="Application Id"/>
> >>  >>   name="nameApp"
> >>   required

Re: using unknown number of databases having the same "structure"

2006-04-20 Thread Guy Galil
I have a situation in my applications that I need to switch databases
dynamically - I use a pretty old version of Torque (3.02) so I had to
tweak it a little but basically what I do is get the Configuration
object, modify the properties in it and re-configure Torque:

public static final String URL = "dsfactory.logic_name.connection.url";
public static  void switchDatabase(String logicName, String oldDatabase,
String newDatabase) throws Exception
{
Configuration config = Torque.getConfiguration();
String key = URL.replaceAll("logic_name",logicName);
String url = config.getString(key);
if(url == null)
throw new InvalidArgumentException("Wrong logic name - 
"+logicName);
url = url.replaceAll(oldDatabase, newDatabase);
config.setProperty(key, url);
Torque.reConfig(config);
}

Note that Torque.reConfig(Configuration config); is a method I added
because in that version Torque.init(Configuration) was not re-entrant, I
think it is fixed in later versions.
Guy

On Thu, 2006-04-20 at 09:55 -0400, Eustache wrote:
> OK sorry for not being clear:
> It's a single web app that wants to have access to several databases at 
> runtime.
> Roughly: the user can select the database he is going to work on, and he 
> can even use this webapp to add a new database he is going to work on.
> Those databases have the same structure though.
> I hope this helps clarify
> 
> >Before I answer this, it would be nice to know more about
> >how you are defining "using multiple databases".  In 
> >particular, are you talking about multiple separate 
> >instances of your code, each using different DB's (e.g
> >multiple web applications) or a single monolithic code
> >base that does this (e.g a single web application or
> >standalone application).
> >
> >  
> >
> >>-Original Message-
> >>From: Eustache [mailto:[EMAIL PROTECTED] 
> >>Sent: Thursday, April 20, 2006 9:44 AM
> >>To: torque-user@db.apache.org
> >>Subject: using unknown number of databases having the same "structure"
> >>
> >>
> >>Hi, maybe somebody can give me an idea or point me to some resource:
> >>I have several databases having the same structure but the number of 
> >>databases and their name are not known at design time (I have another 
> >>database to remember all that).
> >>I would like to be able to use Torque generated classes with 
> >>parameters 
> >>at runtime (db name, host, user, etc.).
> >>Of course I would like to generate only one bunch of classes for all 
> >>these databases since they have the same structure.
> >>I looked at DB Schema support 
> >>http://db.apache.org/torque/releases/torque-3.2/docs-all-compo
> >>
> >>
> >nents/other-howtos/schema-howto.html
> >but I don't think it is what I want.
> >I also looked at "using Torque with multiple databases" but it is only 
> >part of the answer because first I would like to make this configuration
> >
> >dynamic (at runtime) and second the generated classes sould use a 
> >"parameterized" database name (not sure there).
> >Any ideas ?
> >Thx very much,
> >
> >-
> >To unsubscribe, e-mail: [EMAIL PROTECTED]
> >For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >Duke CE Privacy Statement
> >Please be advised that this e-mail and any files transmitted with it are 
> >confidential communication or may otherwise be privileged or confidential 
> >and are intended solely for the individual or entity to whom they are 
> >addressed.  If you are not the intended recipient you may not rely on the 
> >contents of this email or any attachments, and we ask that you  please not 
> >read, copy or retransmit this communication, but reply to the sender and 
> >destroy the email, its contents, and all copies thereof immediately.  Any 
> >unauthorized dissemination, distribution or copying of this communication is 
> >strictly prohibited.
> >
> >
> >
> >-
> >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]
> 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: using a second database

2006-04-18 Thread Guy Galil
All you need to do is change the url string in your torque.properties
file - each developer should have the url point to a different database:
as long as in your schema your database name is 
for developer 1
torque.dsfactory..connection.url
=jdbc:mysql://:/sandbox1

for developer 2
torque.dsfactory..connection.url
=jdbc:mysql://:/sandbox2

The database name in the schema and the objects is just a logical
pointer to the settings in the properties file.

On Tue, 2006-04-18 at 11:27 -0700, Helge Weissig wrote:
> On Apr 17, 2006, at 12:36 PM, Thomas Vandahl wrote:
> 
> > Yes, you can still do that. The name in the schema and the name in  
> > the Torque configuration have nothing to do with the real name of  
> > the database. This is usually specified in the JDBC-URL only. The  
> > other two names are just used to handle the matching of generated  
> > objects and configurations appropriately.
> >
> > I for example do this as well: The name of my schema is "turbine"  
> > and the name of my developer database is "testdb".
> 
> ok, so now I am confused! I played around with different settings and  
> I thought I had it down: The db name in the schema.xml file is  
> inserted into the create-db.sql script and into all generated  
> BasePeer objects and the configuration name in the Torque.properties  
> file needs to be the same as well. Hence, if we want folks to work in  
> their own sandbox, we would have to have
> 
> ...
> torque.database.default=sandbox1
> torque.dsfactory.sandbox1.factory=org.apache.torque.dsfactory.PerUserPoo 
> lDataSourceFactory
> torque.dsfactory.sandbox1. ...
> 
> I can see how you can work around that by enforcing manual creation  
> of the db though. Maybe the lesser of the two not-so-evils?
> 
> cheers,
> h.
> 
> -
> 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]



Re: Custom BaseObject and BasePeer

2006-02-02 Thread Guy Galil
In Torque.jar look for all files with extension .vm 
To change BaseObject and BasePeer you need to look at om/Object.vm and
om/Peer.vm

As to how to edit them see the following reference from Bobbi Fox who
did a lot of work on this here:
"From
http://mail-archives.apache.org/mod_mbox/db-torque-user/200410.mbox/%
[EMAIL PROTECTED]
> 
 I end up at http://www.devaki.org/nextobjects/torque-type-map.html
 which tells you how Torque translates data types.
> 
 I found the message you were responding to; at
http://db.apache.org/torque-32/generator/properties-reference.html
 You can see that the build.properties files tells you where the
template
 path is, and the .vm files are in ${template_path}/om
> 
 Once you locate the .vm files, you can see what their doing, and figure
 out how to modify them. On Thu, 2006-02-02 at 17:28 +0100, Matteo"


 Barbieri wrote:
> I can't find those templates, where are they?
> Are they simple to modify?
> Thanks.
> 
> >The Base objects are generated using velocity templates - by default the
> >templates in the Torque jar are used - you can modify the
> >build.properties file to use the templates in some other location by
> >changing useClasspath=false and pointing templatePath to where your
> >templates are.
> >If you want any code to be added in any generated class add it in the
> >template and regenerate your classes.
> >On Thu, 2006-02-02 at 16:45 +0100, Matteo Barbieri wrote:
> >  
> >
> >>Hi,
> >>I have a question:
> >>I need some methods in all objects, obviusly I don't want to write them
> >>on each Base class, and I don't want to modify the BaseObject class.
> >>Is it possible to tell the generator that all Base classes have to
> >>extend MyCustomBaseObject (that extends BaseObject and implements the
> >>methods that I need)?
> >>
> >>Thank you
> >>Bye
> >>
> >>
> 
> -
> 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]



Re: Custom BaseObject and BasePeer

2006-02-02 Thread Guy Galil
The Base objects are generated using velocity templates - by default the
templates in the Torque jar are used - you can modify the
build.properties file to use the templates in some other location by
changing useClasspath=false and pointing templatePath to where your
templates are.
If you want any code to be added in any generated class add it in the
template and regenerate your classes.
On Thu, 2006-02-02 at 16:45 +0100, Matteo Barbieri wrote:
> Hi,
> I have a question:
> I need some methods in all objects, obviusly I don't want to write them
> on each Base class, and I don't want to modify the BaseObject class.
> Is it possible to tell the generator that all Base classes have to
> extend MyCustomBaseObject (that extends BaseObject and implements the
> methods that I need)?
> 
> Thank you
> Bye
> 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



[Fwd: Re: DB user name and password]

2006-02-02 Thread Guy Galil


The Torque class has another init method that gets an
org.apache.commons.configuration.Configuration as a parameter.
You can instantiate a Configuration object from your Torque.properties
file :
Configuration c = (Configuration)
new PropertiesConfiguration(configFile);
and then modify this Configuration object before you ues it to initiate
Torque.

 On Wed, 2006-02-01 at 18:37 -0800, Alex Chen wrote:
> Currently the only way I know is to specify the user name and password 
> for DB connection via torque is through a property file:
> 
> torque.defaults.connection.user = dbuser
> torque.defaults.connection.password = dbpassword
> 
> and then call Torque.init( String propertyFile)
> 
> This is open the chance of someone looking at the file and getting 
> access to the DB.
> 
> Is there other way to initialize Torque so that I can set the DB 
> user/password separately, e.g. via some property setting at runtime?
> 
> Alex
> 
> 
> -
> 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]



Re: Does torque support multiple databases?

2006-01-24 Thread Guy Galil
It does.
The database element in the schema xml refers to a set of properties in
Torque.properties
For instance 
 

...

refers to :
torque.database.some_db.adapter=mysql
torque.dsfactory.some_db.factory=org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory
#torque.dsfactory.some_db.factory=org.apache.torque.dsfactory.TorqueDataSourceFactory
torque.dsfactory.some_db.pool.defaultMaxActive=30
torque.dsfactory.some_db.pool.testOnBorrow=true
torque.dsfactory.some_db.pool.validationQuery=SELECT 1
torque.dsfactory.some_db.connection.driver=org.gjt.mm.mysql.Driver
torque.dsfactory.some_db.connection.url =jdbc:mysql://127.0.0.1/DATABASE
torque.dsfactory.some_db.connection.user = user
torque.dsfactory.some_db.connection.password = password
#torque.dsfactory.some_db.pool.defaultMaxConnections=30
#torque.dsfactory.some_db.pool.maxExpiryTime=3600
#torque.dsfactory.some_db.pool.connectionWaitTimeout=10 

you can have multiple schema xml files and multiple entries in your
Torque.properties


On Tue, 2006-01-24 at 11:49 -0800, David Zhao wrote:
> Hi there,
> 
> Does torque support multiple database schemas? either with the same database
> engines or different ones?
> Thanks,
> 
> David


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Inheritance in database

2005-11-22 Thread Guy Galil
Hi
I use inheritance in a few places, it is a very neat feature - you
should probably look at the documentation but I can give you a simple
example:
I have a table that holds the information used to purge historic data,
the name of objects to purge, the age, purge executor type and
additional data.


 
  



   
   
   
  
  

When I use Torque to retrieve data from this table the list I get
contains objects of type SqlPurgeExcutor or JavaPurgeExcutor according
to the value of PURGE_EXECUTOR_TYPE.

Hope this helps.
Guy
On Sun, 2005-11-20 at 21:54 +0100, Jakub Piechnik wrote:
> Hello
> 
> Has anyone can tell me anything about inheritance in torque schema? I 
> know that there is a key-word inheritance, but what exactly menas key, 
> class, single, etc in this?
> 
> I have a table with 6 columns - one of which is boolean for distinguish 
> which class should be created of inserted data. Both two classes use the 
> same fields - so - can You tell me, how should I set it up in torque?
> 
> I would be vere grateful for any help
> 
> Greetings
> Jakub Piechnik
> 
> -
> 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]



RE: how to write a query with Date type

2005-11-09 Thread Guy Galil
There are ways to use avg() and count() in torque using custom
criterion. 
Search the archives for postings on this.
On Wed, 2005-11-09 at 12:21 -0600, jill han wrote:
> Thanks.
> I formatted java.util.Date object to java.sql.Date format. It worked
> fine.
> 
> I could use Criteria date stuff, but torque 3.1 Criteria could not
> process a query like
> Criteria.addSelectColumn("COUNT(Unique("+aTablePeer.aColumn + "))")
> Or 
> Criteria.addSelectColumn("Round(Avg(" + aTablePeer.aColumn + "), 2)")
> 
> -Original Message-
> From: Dave Newton [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, November 09, 2005 10:22 AM
> To: Apache Torque Users List
> Subject: Re: how to write a query with Date type
> 
> jill han wrote:
> 
> >Below is a piece of code to get records from a table and exception
> >// startDate and endDate are Date object
> >// aDate has Date data type in oracle db
> >String sql = "Select * from aTable ";
> >sql = sql + " Where aDate ";
> >sql = sql + " Between '" + startDate + "' And '" + endDate + "' ";
> >List sqlResult = aTablePeer.executeQuery(sql);
> >
> >org.apache.torque.TorqueException: ORA-01858: a non-numeric character
> >was found where a numeric was expected
> >  
> >
> I'm assuming you're asking why this didn't work.
> 
> java.util.Date's toString returns something along the following lines:
> 
> Wed Nov 09 11:19:05 GMT-05:00 2005
> 
> which isn't what an SQL date looks like (although I don't deal with 
> Oracle much, so I could be completely wrong).
> 
> You'll want to convert it to a format that Oracle understands.
> 
> I thought the Criteria date stuff would do that work for you (I don't 
> know that either, though ) If that's true, is there a reason to avoid 
> Criteria for this usecase?
> 
> Dave
> 
> 
> 
> -
> 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]
> 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Torque not closing database connections

2005-10-03 Thread Guy Galil
I am using Torque 3.0 in our product for over two years with no such
problems.
following is a snippet from our Torque.properties:
torque.database.default.adapter=mysql
torque.dsfactory.default.factory=org.apache.torque.dsfactory.Jdbc2PoolDataSourceFactory
#torque.dsfactory.default.factory=org.apache.torque.dsfactory.TorqueDataSourceFactory
torque.dsfactory.default.pool.defaultMaxActive=30
torque.dsfactory.default.pool.testOnBorrow=true
torque.dsfactory.default.pool.validationQuery=SELECT 1
torque.dsfactory.default.connection.driver=org.gjt.mm.mysql.Driver
torque.dsfactory.default.connection.url =jdbc:mysql://127.0.0.1/tatabase
torque.dsfactory.default.connection.user = user
torque.dsfactory.default.connection.password = password
#torque.dsfactory.default.pool.defaultMaxConnections=30
#torque.dsfactory.default.pool.maxExpiryTime=3600
#torque.dsfactory.default.pool.connectionWaitTimeout=10

torque.idbroker.cleverquantity=true
torque.manager.useCache = true

Good luck Guy
 On Sat, 2005-10-01 at 15:02 +0200, Thomas Fischer wrote:
> 
> 
> 
> No, Torque.shutdown() should be the inverse of Torque.init() and should be
> called only once if the application stops. Among other things, it tries to
> close any database pools generated by Torque.init() if possible.
> I typically put it in the destroy method of the main servlet of my
> application.
> 
>Thomas
> 
> Jim Caserta <[EMAIL PROTECTED]> schrieb am 01.10.2005 14:51:06:
> 
> > Thomas,
> >
> > Is using the Shutdown also recommended as follows?
> >
> > try
> > {
> > db = Torque.getConnection(DATABASE_NAME);
> >  }
> > finally
> > {
> > Torque.closeConnection(db);
> > Torque.shutdown() <<
> > }
> >
> > Jim
> >
> > --- Thomas Fischer <[EMAIL PROTECTED]> wrote:
> >
> > >
> > >
> > >
> > >
> > > I do not know much about Torque 3.0. All I can say
> > > about it is that I did
> > > not hear any problems about this in Torque 3.1 and
> > > later.
> > >
> > > In principal, the reasons can be the following:
> > > 1) the database pool is faulty (threading issues or
> > > similar). You can try
> > > to check this by updating to the newest dbcp version
> > > 1.2.1 and configure
> > > Torque to use it.
> > > 2) There is an error in Torque code somewhere.
> > > Personally, this seems quite
> > > improbable to me.
> > > 3) You do not close the database connections
> > > correctly. For example, the
> > > following is not enough
> > >
> > > Connection connection = Torque.getConnection()
> > > // do something with connection
> > > connection.close();
> > >
> > > because if an exception is happening before you call
> > > close, the connection
> > > will not be closed.
> > >
> > > You need to do something like the following to be on
> > > the safe side (I left
> > > out various catch blocks in order to show the
> > > principle)
> > >
> > > Connection connection = null;
> > > try
> > > {
> > >   connection = Torque.getConnection();
> > >   // do something with connection
> > > }
> > > finally
> > > {
> > >   if (connection != null)
> > >   {
> > > connection.close();
> > > connection = null;
> > >   }
> > > }
> > >
> > > If nothing helps, you need to write a log file when
> > > you open a connection
> > > and when you close the connection and find out where
> > > this happens. This is
> > > best done by subclassing the pool you use.
> > >
> > >  Thomas
> > >
> > >
> > >
> > > "Sandeep Bghavatula" <[EMAIL PROTECTED]>
> > > schrieb am 30.09.2005
> > > 22:18:42:
> > >
> > > > We use torque3.0 with turbine in our web
> > > application. The database
> > > > is mysql. Torque does'nt seem to be closing the
> > > database
> > > > connections. We end up with 50-60 connections in a
> > > couple of days
> > > > and have to restart the tomcat instance every 3
> > > days to keep mysql
> > > > from throwing up and saying thats it!! In my code,
> > > I do a
> > > > connection.close() wherever I have a
> > > Torque.getConnection(). There
> > > > is nothing in the database logs. Here is my
> > > torque.properties file.
> > > > Please help!!!
> > > >
> > > > #
> > >
> > ---
> > > > # $Id: Torque.properties,v 1.1 2005/08/25 17:51:16
> > > jriley Exp $
> > > > #
> > > > # This is the configuration file for Torque.
> > > > #
> > > > # Note that strings containing "," (comma)
> > > characters must backslash
> > > > # escape the comma (i.e. '\,')
> > > > #
> > > > #
> > >
> > ---
> > > >
> > > > # NOTE NO torque. prefix on properties - this is a
> > > kluge to make it
> > > > also include the TR.properties
> > > >
> > > > torque.applicationRoot=.
> > > >
> > > > #
> > >
> > ---
> > > > #
> > > > #  L O G G I N G
> > > > #
> > > > #
> > >
> > ---
> >

Re: Problem with doDelete

2005-06-05 Thread guy galil
The way to use the same column twice in one statement
is as follows:
Criteria c = new Criteria();
c.add(Time.EDATE, d1, Criteria.GREATER_EQUAL);
Criteria.Criterion criterion =
c.getCriterion(Time.EDATE);
criterion.and(
   c.getNewCriterion(
criterion.getTable(),
criterion.getColumn(),
 d2,
 Criteria.LESS_EQUAL )
 );
 Time.doDelete(c, conn);

--- Kalyani Kale <[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I have a problem with doDelete of torque. This is a
> sample piece of my
> code.
> 
>  
> 
> conn = Transaction.beginOptional( "db", true );
> 
>  
> 
> DateFormat df = new SimpleDateFormat("MM/dd/");
> 
> Date d1 = df.parse("05/15/2005");
> 
> Date d2 = df.parse("05/21/2005");
> 
> 
> 
> Criteria c = new Criteria();
> 
> c.add(Time.LOGINID, getLoginID());  
>   
> 
> c.add(Time.EDATE, d1, Criteria.GREATER_EQUAL);
> 
> c.add(Time.EDATE, d2, Criteria.LESS_EQUAL);
> 
> 
> 
> Time.doDelete(c, conn);
> 
>  
> 
> Transaction.commit( conn );
> 
>  
> 
> Now, ideally this should delete the records of Time
> table having EDate
> between 15th May 2005 and 22nd May 2005.
> 
> But it does not consider date d2 at all and deletes
> all the records that
> are greater than d1.
> 
>  
> 
> What could be the problem?
> 
>  
> 
> Thanx,
> 
> Kalyani
> 
>  
> 
> 

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: change of base configuration at runtime

2005-05-24 Thread Guy Galil
Following is the message I posted on this subject on August 04.
Note that I am using an old version of Torque and that I had to modify
Torque.java to get this to work - My impression was that
Torque.shutDown() does not do what it is supposed to do, One problem I
had to fix was that Torque.initialize() is not reentrant - it
initializes logging which should be done only once and it sets - 
mapBuilders = null; which results in a nullPointerException
I dont know if this is true in newer versions.
Cheers Guy



>We change database host as well as other properties at runtime.
> We are using an old version of Torque - 3.02
> In order to achieve this I had to modify org.apache.torque.Torque.java
> so that it is re-entrant and added a reConfig(Configuration c) method.
> Then in my code I created a utility class that can be used to change the
> configuration at runtime:
> 
> public static  void changeDbHost(String logicName, String host) throws
> TorqueException
> {
>   Configuration config = Torque.getConfiguration();
>   
> replaceProperty(config,URL.replaceAll("logic_name",logicName),"jdbc:mysql://"+host+"/DATABASE");
>   Torque.reConfig(config);
> }
> 
> public static void replaceProperty(Configuration config, String key,
> String value)
> {
>   if(config.containsKey(key))
>   config.setProperty(key, value);
>   else
>   config.addProperty(key, value); 
> }
> This works well for me.
> I understand that Torque changed since the version I use and my
> modifications to Torque.java are either not needed or not compatible
> with the latest code, I am willing to send my Torque.java if you are
> interested.
> Guy
> 

On Tue, 2005-05-24 at 12:01 +0200, Lionel Pasquier wrote:
> I know you posted something about it, but I was unable to retrieve the 
> thread.
> 
> What I tried to do was also:
> 
> Configuration torqueconf = Torque.getConfiguration();
> torqueconf.setProperty("torque.dsfactory.mydb.connection.url", 
> newproperties.get("torque.dsfactory.mydb.connection.url"));
> torqueconf.setProperty("torque.dsfactory.customer.connection.user", 
> newproperties.get("torque.dsfactory.customer.connection.user"));
> torqueconf.setProperty("torque.dsfactory.customer.connection.password", 
> newproperties.get("torque.dsfactory.customer.connection.password"));
> Torque.setConfiguration(torqueconf);
> Torque.getInstance().shutdown(); // with or without
> Torque.getInstance().init(ConfigurationConverter.getConfiguration(properties));
> 
> But this led me to the a Nullpointer (db = 
> Torque.getDB(criteria.getDbName()) is null) if the shutdown is present, 
> and to contacting the wrong DB is the shutdown is not present.
> 
> Could you re-post your solution?
> 
> 
> Guy Galil wrote:
> 
> >It depends on the version of Torque you use.
> >I posted a solution for Torque 3.02 a while ago, The idea is to get the
> >Configuration object, change some
> >settings and reconfigure Torque.
> >It requires some digging into the Torque code but is doable.
> >I can provide the 3.02 code if you want but I know those things changed
> >since that version.
> >On Mon, 2005-05-23 at 18:55 +0200, Lionel Pasquier wrote:
> >  
> >
> >>Hello,
> >>
> >>I 've read a few threads on this mailing list about the problem of 
> >>changing of database configuration using:
> >>Torque.init(pathToConf);
> >>Torque.shutdown();
> >>Torque.init(newPathOfConf);
> >>
> >>Unfortunatly I still have the classic NullpointerException at any torque 
> >>access after the 2nd init.
> >>
> >>Has anyone solved this problem and knows a workaround?
> >>
> >>Lionel
> >>
> >>
> >>
> >>-
> >>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]
> >
> >
> >  
> >
> 
> 
> 
> -
> 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]



Re: change of base configuration at runtime

2005-05-23 Thread Guy Galil
It depends on the version of Torque you use.
I posted a solution for Torque 3.02 a while ago, The idea is to get the
Configuration object, change some
settings and reconfigure Torque.
It requires some digging into the Torque code but is doable.
I can provide the 3.02 code if you want but I know those things changed
since that version.
On Mon, 2005-05-23 at 18:55 +0200, Lionel Pasquier wrote:
> Hello,
> 
> I 've read a few threads on this mailing list about the problem of 
> changing of database configuration using:
> Torque.init(pathToConf);
> Torque.shutdown();
> Torque.init(newPathOfConf);
> 
> Unfortunatly I still have the classic NullpointerException at any torque 
> access after the 2nd init.
> 
> Has anyone solved this problem and knows a workaround?
> 
> Lionel
> 
> 
> 
> -
> 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]



RE: TorqueInstance & non-static initialization Help!

2005-05-18 Thread Guy Galil
I dont think you need multiple Torque instances.
You can have separate schema xml files for the different databases and
different database names specified in the schema and in
Torque.properties.
Then to get a connection explicitly you can use
Torque.getConnection(dbName);
The generated Torque objects will use the database specified as dbName
in the schema xml file:
 We use a legacy database running on a VMS system which is nearly
> impossible query. There are a few programs written to query specific
> data via flat files, but the majority of interaction with it is with a
> terminal/telnet session.  Unfortunately, migrating to a modern system
> isn't possible at this time. In an effort to provide more functionally
> and ease of use to our customers, I want to provide more (web)tools
> online to place orders, check order status, view account information,
> etc... 
> 
> My solution is to simply mirror some of the tables in the legacy
> database with mysql. This has been a difficult process, but Torque has
> eased the transition. 
> 
> My problem now is when the same application needs to access our mirrored
> database and some other unrelated database/table. (Both residing in
> mysql) What I would like to do is have one api for the mirrored
> database, and separate api's for other databases/tables. 
> 
> For Example, I'll call our mirrored legacy database 'mirror' which
> contains the tables 'product', 'order', and 'customer'. 
> 
> mirror
>product
>order
>customer
> 
> Now, lets say I have another db named 'salesmen' with tables 'employee'
> and 'territory'. Assume this database has no equivalent in the legacy
> database.
> 
> salesmen
>   employee
>   territory
> 
> 
> Now let's say we have some business operation that requires us to access
> both databases. I don't want to build my Torque schema in such a way
> that it must encompass all of our databases. I want to segregate the
> mirrored database api in order to keep things consistent within it. 
> 
> In order for something like this to work, I'd need to do something along
> the lines of:
> 
> TorqueInstance mirror = new TorqueInstance();
> mirror.init("Mirror.properties");
> 
> TorqueInstance salesmen = new TorqueInstance();
> salesmen.init("Salesmen.properties");
> 
> 
> In the event that I would want add another table to the mirrored
> database, or perform some other maintenance, I wouldn't affect the
> 'salesmen' torque api. Also, when one application only requires access
> to one of the databases, say 'salesmen', I wouldn't have to load the
> 'mirror' torque api. 
> 
> Perhaps another way to go about this would be to extend the Torque class
> and hard code the database names into it per schema. 
> 
> static TorqueMirror extends Torque
> All references in BaseProduct, Product, BaseProductPeer, ProductPeer
> would reference TorqueMirror rather than Torque. (the same for other
> tables in this db)
> 
> static TorqueSalesmen extends Torque 
> All references in BaseEmployee, Product, BaseEmployeePeer, EmployeePeer
> would reference TorqueSalesmen rather than Torque. (the same for other
> tables in this db)
> 
> Then we could initialize by:
> TorqueMirror.init("mirror.properties");
> TorqueSalesmen.init("salesmen.properties");
> 
> 
> 
> I understand that I can multiple databases in the torque schema, but I
> want to avoid having one torque generated api to encompass any and all
> database access. 
> 
> 
> Aaron
> 
> 
> 
>  
> 
> 
> -Original Message-
> From: Thomas Fischer [mailto:[EMAIL PROTECTED] 
> Sent: Wednesday, May 18, 2005 8:46 AM
> To: Apache Torque Users List
> Subject: RE: TorqueInstance & non-static initialization Help!
> 
> 
> 
> 
> 
> Hi Aaron,
> 
> at the moment, the TorqueInstance is a singleton, and as such, it is not
> possible to have multiple instances at the moment.
> I believe that this can not be changed easily. E.g. the peer classes
> rely
> on TorqueInstance being a Singleton for retrieving a connection, and I
> see
> no easy way to tell the Peer clases which instance they should use, if
> there are multiple instances.
> 
> What do you need the multiple instances of Torque for ?
> 
>   Thomas
> 
> 
> "Aaron Loucks" <[EMAIL PROTECTED]> schrieb am 18.05.2005 14:14:51:
> 
> >
> > EDIT:
> > Criteria c = new Criteria(ProductPeer.DATA_BASE_NAME);
> >
> >
> > From: Aaron Loucks [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, May 17, 2005 5:02 PM
> > To: Apache Torque Users List
> > Subject: TorqueInstance & non-static initialization Help!
> >
> > I'm trying to initialize torque in a non-static way so that I can have
> > multiple instances (for different databases/functionality) in a single
> > web application.
> >
> > I tried initializing a TorqueInstance and pass the database name and
> > connection to a peer class, without success:
> >
> > ...
> >
> > TorqueInstance torqueInstance = new TorqueInstance();
> > torqueInstance.setConfiguration(config);
> > torqueInstance.initalize();
> >
> > Criteria c = ProductPeer.DA

Re: Torque and jsp

2005-03-15 Thread Guy Galil
another alternative when you initiate Torque in  a servlet is to get the
actual full path from the servlet:

ServletContext ctxt = getServletContext();
String path = ctxt.getRealPath("/")+"/WEB-INF/conf/";
Torque.init(path+"Torque.properties");


 On Tue, 2005-03-15 at 09:48, Andras Balogh wrote:
> Hello,
> 
> Why don't You put the torque.properties file in WEB-INF/classes/ and 
> load it like this:
> if(!Torque.isInit())
> {
> PropertiesConfiguration pc = new PropertiesConfiguration();
> pc.load( 
> this.getClass().getClassLoader().getResourceAsStream("torque.properties") );
>
> Torque.init(pc);
>  }
> This way You don't have to hardcode any path and it will work on any 
> deployment.
> I use this  in a Servlet but I don't see why it wouldn't work in a jsp too.
> 
> Best regards,
> Andras.
> 
> 
> [EMAIL PROTECTED] wrote:
> 
> >Torque.init() requires an absolute pathname. It's a bummer.
> >
> >I put the true pathname in another properties file so that I do not have to
> >hard-code it in the program. This does mean, however, that I have to know
> >the absolute path where, in my case, Tomcat is installed. Here is my
> >initialisation code
> >
> >apiResources = ResourceBundle.getBundle("betapi");
> >if (!Torque.isInit()) {
> >String configFile = apiResources.getString
> >("betapi.torqueconfig");
> >try {
> >Torque.init(configFile);
> >} catch (TorqueException e) {
> >  context.log(e,"Cannot initalise Torque: " + e.toString()
> >);
> >e.printStackTrace(System.err);
> >System.exit(1);
> >}
> >}
> >
> >and betapi.properties contains:
> >  betapi.torqueconfig=
> >/users/rxm1676/workspace/pmfeditor/WEB-INF/classes/Torque.properties
> >
> >
> >In cases where I build on one machine but run on another I have a little
> >shell script that that runs on installation. It tracks down the appropriate
> >line in betapi.properties and adjusts it so suit where the code is actually
> >installed.
> >
> >  
> >
> 
> 
> -
> 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]



Re: Torque and jsp

2005-03-15 Thread Guy Galil
You can pass the full path to the Torque.properties file as a parameter
to Torque.init() 

On Tue, 2005-03-15 at 09:19, salwa idrissi wrote:
> the problem is not confusing presentation and model but when i compile in 
> jdev i have the exception "Could not open file Torque.properties"because i 
> must put it in a specific directory in jdev that i don't know.
> 
> this is the code:
> 
> affichage.jsp:
> 
> 
>  class="textindex"> 
> <%
> Iterator i;
> List listecr=(List)session.getAttribute("liste");
>  i = listecr.iterator();
>  while ( i.hasNext() )
>  {
>   Ecriture monecriture = (Ecriture) i.next();
> %>
>
>
>   <%= monecriture.getCodeetape()%>
>
>
>
> <%
>  }
> %>
>  
> 
>  
> 
> actionaccueil.java
> 
> 
>   public ActionForward execute(ActionMapping mapping, ActionForm form, 
> HttpServletRequest request, HttpServletResponse response) throws IOException, 
> ServletException
>   {
> HttpSession session=request.getSession();
> 
> AddEcriture test=new AddEcriture();
> test.afficher();
> 
> session.setAttribute("liste",test.getListecrs());
> return mapping.findForward("success");
>   }
> }
> 
> AddEcriture.java:
> 
>  
> 
> package si.av;
> 
> import java.util.*;
> import org.apache.torque.Torque;
> import org.apache.torque.util.Criteria;
> import si.av.om.*;
> 
> public class AddEcriture
> {
> 
>  List listecrs;
>  public List getListecrs()
>  {return listecrs;}
>  
>   public void afficher()
>   {
>   try{
>   Torque.init("Torque.properties");
> 
>  Criteria critaffichage=new Criteria();
>   critaffichage.addAscendingOrderByColumn(EcriturePeer.NSEQUENCE);
>   listecrs=EcriturePeer.doSelect(critaffichage);
>   
>   }
>   
>   catch(Exception e){e.printStackTrace();}
>   }
> 
> }
> 
>   
> -
>  DÃcouvrez nos promotions exclusives "destination de la Tunisie, du Maroc, 
> des BalÃares et la RÃp. Dominicaine sur Yahoo! Voyages. 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: use same conf with more than one databases

2005-02-04 Thread Guy Galil
What's hardcoded in the base classes is a logical name that points to
settings in Torque.properties - if you have each developer use a
different properties file then they can access different databases.
Another alternative is to override the hardcoded database name by
specifying a database name on each torque method call, all Torque
methods such as save, doSelect, delete can be called with either a
String database name or a connection object, off-course this might
require massive code changes.
The third alternative is to change configuration at run time, I have
code that do this for Torque 3.02 that does not work with newer
versions. The idea is to get the Configuration object, change some
settings and reconfigure Torque.
It requires some digging into the Torque code but is doable.
I can provide the 3.02 code if you want but I know those things changed
since that version.
 
On Fri, 2005-02-04 at 15:05, ÎÎÏÏÎÎÏ ÎÎÎÏÎÏÎÏ wrote:
> Hello,
> 
> In a quite large project we need to use a different database for each 
> developer. The schema is obviously the same for each one, but it turns 
> out that even if we change the torque.properties and build.properties 
> files, we still have to rebuild and compile everything because the 
> connection info is hardcoded into the autogenerated Base* classes.
> 
> Is there any way to get around this? After a while it has proven to be 
> really annoying...
> 
> Cheers,
> Antonis.
> 
> 
> -
> 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]



Re: Torque Future planning / wishlist

2004-12-23 Thread Guy Galil
I don't know if this is in the scope of torque project but it is an
AWESOME idea

On Thu, 2004-12-23 at 08:10, Charles-Alexandre Sabourdin wrote:
> Le mardi 21 DÃcembre 2004 10:32, Henning P. Schmiedehausen a Ãcrit :
> > http://wiki.apache.org/db-torque/TorqueFuture
> I cannot edit that page so I add the following suggestion :
> 
> in 1.3. Torque Code generator
>  - genarate struts pages. the idea would be to create a jsp pages form with 
> all the fields by pages, the struts-config.xml, the validator-rules.xml and 
> the {table}Form.java and {table}Action.java. this looks like Xdoclet but; 
> this could be great
> 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: connection leak

2004-12-23 Thread Guy Galil
When you take a Torque connection explicitly you must close it.
If you put the call to Torque.closeConnection(con) in a finally{...}
clause then it will be called even when an error occurs

On Thu, 2004-12-23 at 12:01, Husek, Paul wrote:
> Hello,
> 
>  
> 
> I'm using torque 3.1 and am experiencing what I believe to be a connection
> leak.  The symptoms are that eventually the application just stops
> responding and seems to be stuck where it would normally be fetching a db
> connection.This is probably due to the fact that I occasionally need to
> construct my own queries and do a Torque.getConnection, and due to errors
> may not be able to release the connection.
> 
>  
> 
> I've seen mention of abandoned connection management via DBCP, but I could
> never get it working.  I just upgraded to dbcp 1.2, and I still can't get it
> working.  Does anyone have a Torque.properties that properly handles
> abandoned connections (and has been verified)?
> 
>  
> 
> 
> 
> 
> 
> 
> 
> 
> 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Inheritance

2004-11-17 Thread Guy Galil
As I understand it since bothe Resource and HumanResource classes are
based on the same database table all columns are visible by both,
inheritance is useful when you need to implement different processing
not for different attributes.

  On Wed, 2004-11-17 at 08:01, Christian Plate wrote:
> Hello Torque-users,
> 
> I have problem with Inheritance and Torque. The Inheritance Guide 
> (http://www.ingrid.org/jajakarta/turbine/en/turbine/torque/inheritance-guide.html)
>  
> describes how to define a subclass.
> 
> But I can't find a way to define extra columns for my subclass.
> 
> The example below works great, a subclass HumanResource is generated. But how 
> do i get extra columns for HumanResources?
> 
> Thanks in advance,
>   Christian
> 
> 
>name="id"
>   required="true"
>   primaryKey="true"
>   type="INTEGER"
> />
>name="name"
>   type="VARCHAR"
>   description="Name of this Resource"/>
> />
>   name="class_type"
>  type="VARCHAR"
>  inheritance="single">
>class="HumanResource"
> extends="Resource"/>
> 
> 
> name="class_type"
>  type="VARCHAR"
>  inheritance="single">
>class="HumanResource"
> extends="Resource"/>
> 
> 
> 
> -
> 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]



Re: Key problems - Torque 3.1.1

2004-11-15 Thread Guy Galil
I think the problem is with the id being an auto increment column - if u
set it to be autoIncrement="false" on the target database then you will
be able to put the correct value in there.
Guy
On Mon, 2004-11-15 at 14:53, Kris Nuttycombe wrote:
> Hi, all,
> 
> Torque's driving me a bit batty this morning. Here is the problem: I'm 
> trying to use Torque to facilitate transfers from one database to 
> another, but it seems like I can't set the primary keys in the 
> destination database correctly. Here is an example of code that is 
> supposed to do this:
> 
> /**
>  * This method will transfer a template set from the source database to
>  * [EMAIL PROTECTED] #getDestSetId() destSetId} in the destination 
> database.
>  */
> private void transferTemplateSet(Connection sourceConnection, 
> Connection destConnection) throws TorqueException {
> Criteria dcrit = new Criteria();
> dcrit.add(DataInfoPeer.ID, this.destSetId);
> List destList = DataInfoPeer.doSelect(dcrit, destConnection);
>
> if (destList.isEmpty() || this.updateSet) {
> Criteria crit = new Criteria();
> crit.add(DataInfoPeer.ID, this.sourceSetId);
> List sourceList = DataInfoPeer.doSelect(crit, sourceConnection);
> log.info(sourceList.size() + " entries found in the source 
> database for data set " + this.sourceSetId);
> 
> if (!sourceList.isEmpty()) {
> DataInfo source = (DataInfo) sourceList.get(0);
> DataInfo dest =  source.copy();
> dest.setId(this.destSetId);
> if (this.dataSourceOverride > 0) 
> dest.setDataSourceId(this.dataSourceOverride);
> 
> log.debug("Saving record " + dest.toString());
> dest.save(destConnection);
> }
> }
> }
> 
> To facilitate this, I had to patch Object.vm and Peer.vm to run a query 
> for isNew() instead of just using the boolean property, since I'm 
> copying the source object and setting the primary keys and I don't know 
> in advance whether or not the object exists in the destination database. 
> Here are the patches I use:
> 
> Object.vm:
> 
> ***
> *** 1143,1149 
>   // If this object has been modified, then save it to the 
> database.
>   if (isModified())
>   {
> ! if (isNew())
>   {
>   ${table.JavaName}Peer.doInsert(($table.JavaName) 
> this, con);
>   setNew(false);
> --- 1143,1149 
>   // If this object has been modified, then save it to the 
> database.
>   if (isModified())
>   {
> ! if (isNew(con))
>   {
>   ${table.JavaName}Peer.doInsert(($table.JavaName) 
> this, con);
>   setNew(false);
> ***
> *** 1190,1195 
> --- 1190,1207 
>   alreadyInSave = false;
>   }
> #end
> + }
> +
> + /**
> +  * Check whether the object already exists in the database.
> +  * Used to determine whether to insert or update. This is more
> +  * expensive than using the boolean isNew() flag, but allows
> +  * much nicer handling for IDB applications. -Kris Nuttycombe
> +  */
> + public boolean isNew(Connection con) throws TorqueException {
> + Criteria criteria = 
> ${table.JavaName}Peer.buildCriteria(this.getPrimaryKey());
> + List list =  ${table.JavaName}Peer.doSelect(criteria, con);
> + return list.isEmpty();
>   }
>   #end
> 
> Peer.vm:
> 
> ***
> *** 53,62 
>   #if (!$table.isAlias())
> 
>   /** the default database name for this class */
> ! public static final String DATABASE_NAME = "$table.Database.Name";
> 
>/** the table name for this class */
> ! public static final String TABLE_NAME = "$table.Name";
> 
>   /**
>* @return the map builder for this peer
> --- 53,62 
>   #if (!$table.isAlias())
> 
>   /** the default database name for this class */
> ! public static final String __DATABASE_NAME__ = "$table.Database.Name";
> 
>/** the table name for this class */
> ! public static final String __TABLE_NAME__ = "$table.Name";
> 
>   /**
>* @return the map builder for this peer
> ***
> *** 612,618 
>   public static void doUpdate(Criteria criteria, Connection con)
>   throws TorqueException
>   {
> ! Criteria selectCriteria = new Criteria(DATABASE_NAME, 2);
> #foreach ($col in $table.Columns)
>   #set ( $cup=$col.Name.toUpperCase() )
>   #if($col.isBooleanInt())
> --- 612,618 
>   public static void doUpdate(Criteria criteria, Connection con)
>   throws TorqueException
>   {
> ! Criteria selectCriteria = new Criteria(__DATABASE_NAME__, 2);
> #foreach ($col in $table.Columns)
>   #

Re: Unable to create Criteria object or executeQuery

2004-11-12 Thread Guy Galil
The error message you get indicates a configuration problem - check your
Torque.properties.
After you are able to connect you can use your code as listed and get a
List of Reccord objects with your results - Torque cannot map multiple
tables to specific objects.
Another way would be to use Torque just to get the connection and then
process the query using plain jdbc:

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;



Connection con = null;
Statement st = null;
ResultSet rs = null;
String query = "Select a from b where c = 'd' ";
try
{
con = Torque.getConnection("default_database");
st = con.createStatement();
rs = st.executeQuery(query);
while (rs.next()) 
{
// process results
}
}   
finally
{
if (rs != null)
rs.close();
if(st != null)
st.close(); 
Torque.closeConnection(con);
}





On Fri, 2004-11-12 at 09:27, Pritam Paul wrote:
> Hi,
> 
> I have the following sql statement whose equivalent i need to generated using 
> Criteria settings to fetch the results:
> 
> [THIS SQL Query works well in SQL Server and Query explorer - to fetch 8 
> records]
> -
> SELECTPME_EmpInfo.EMPLOYEEID, 
>   PME_EmpInfo.FIRSTNAME, 
>   PME_EmpInfo.LASTNAME, 
>   PME_EmpInfo.SUPERVISORID, 
>   PME_EmpInfo.DEPTNO, 
>   PME_EmpInfo.DEPTNAME, 
>   (SELECT (empinner.FirstName + ' ' + 
> empinner.LastName) 
> FROM  PME_EmpInfo empinner 
> WHERE PME_EmpInfo.SUPERVISORID = 
> empinner.EmployeeID) AS SupervisorName,
>   (SELECT phaseinner.PhaseName 
> FROM  PME_Phase phaseinner 
> WHERE PME_Main.CURRENTPHASEID = 
> phaseinner.PhaseID) AS PhaseName 
> 
> FROM  PME_EmpInfo INNER JOIN 
>   PME_Main ON PME_EmpInfo.EMPLOYEEID = PME_Main.EMPLOYEEID INNER 
> JOIN 
>   PME_Phase ON PME_Main.CURRENTPHASEID = PME_Phase.PHASEID 
> WHERE (PME_Main.CURRENTSTATUSID='7') AND 
> (PME_EmpInfo.DEPTNO='11080')
> 
> -
> 
> I tried using Criteria class but since i dont know Torque well i dont know how
> this can be achieved using the Criteria class. I tried creating a Query object
> for this SQL statement and its (.toString()) method outputs this exact SQL 
> query.
> 
> But how do i execute this query to fetch the results. 
> 
> When i try using the BasePeer.executeQuery(sqlString) method, it complains 
> "There was no DataSourceFactory configured for the connection".
> 
> Also how would i get the resultset object casted in such a way that i can 
> read the mentioned columns.
> 
> In summary - how to execute a raw sql statement (which was generated by some 
> other
> app layer) using torque and get the resultset?
> 
> Any help is greatly appreciated.
> 
> regards,
> Paul
> 
> 


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Real-time database fetch with Velocity/Struts/Torque?

2004-11-01 Thread Guy Galil
First you need to know the struts mechanisms.
Then it is easy to use Torque in the struts action to build a Criteria,
get a list of Torque objects, place them in your form bean.
Then use struts logic:iterate tag to get the options into your jsp.
Both struts and torque are pretty strait forward but you need to learn
both - once you do these frameworks can save you lot's of development
effort
On Mon, 2004-11-01 at 08:53, William Wong wrote:
> Hi All,
>  
> I'm thinking to implement something like this 
>  
> http://www.atgconsulting.com/gofetch.asp
>  
> with Velocity/Struts/Torque. Basically, I need to load information real-time
> from DB and fill up an option box. Does anybody has any examples that use
> these technologies?
>  
> Thanks and regards,
> William
>  


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Releasing DB connections

2004-08-27 Thread Guy Galil
If you use Connection con = Torque.getConnection() to get the connection
then you should use Torque.closeConnection(con) to close it:

try
{
Connection con = Torque.getConnection();
/* use your connection here
...
...
*/
}
finally
{
Torque.closeConnection(con);
}

I don't think transactions has anything to do with this.


On Fri, 2004-08-27 at 04:21, [EMAIL PROTECTED] wrote:
> A bit of clarification please.
> 
> One uses torque.getConnection to get a DB connection from the pool. How and
> when is it returned to the pool?
> 
> 
> 
> 
> -
> 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]



using secured database connection

2004-07-19 Thread Guy Galil
We are using Torque with MySql.
>From MySql documentation on connecting to database using ssl:
"You will also need to set 'useSSL' to 'true' in your connection
parameters for MySQL Connector/J, either by adding 'useSSL=true' to your
URL, or by setting the property 'useSSL' to 'true' in the
java.util.Properties instance you pass to
DriverManager.getConnection()."

I tried appending 'useSSL=true' to the database url in Torque.properties -
torque.dsfactory.default.connection.url = 
jdbc:mysql://localhost:3306/TURBINE?useSSL=true
but it was ignored.
Any help will be appreciated
Guy



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]