Hello,

I've got a problem getting Torque to work inside a servlet in a Tomcat
environment: I will try to describe the situation as good as I can. Thanks
for your help!

I've succeeded in getting Torque to generate classes and SQL files according
to my schema - and with the help of some information from this mailing-list
I have also succeeded in building a small class that uses Torque and
performs an Insert and a Select 

-> I've got a torque.properties file that works (at least in the IDE
environment). 
Here are the database settings that I use:

torque.database.default= bookstore
torque.database.bookstore.adapter= mysql

Using commons-dbcp 
torque.dsfactory.bookstore.factory=org.apache.torque.dsfactory.PerUserPoolDa
taSourceFactory
torque.dsfactory.bookstore.pool.defaultMaxActive=10
torque.dsfactory.bookstore.pool.testOnBorrow=true
torque.dsfactory.bookstore.connection.driver = org.gjt.mm.mysql.Driver 
torque.dsfactory.bookstore.connection.url =
jdbc:mysql://127.0.0.1:3306/bookstore 
torque.dsfactory.bookstore.connection.user = torque_test
torque.dsfactory.bookstore.connection.password = ;-)

The runtime usage of Torque works within a class that runs inside my eclipse
IDE with all the jar files from the torque-3.1\lib added to the build path.
The three Methods that I use for testing are: (these methods work fine when
testing from inside eclipse, of course, using a System.out.println() rather
than the PrintWriter that I use for testing on Tomcat)

public static void checkTorque(PrintWriter out){
                out.println("Is Torque initiated?  ... "+Torque.isInit());

        } 

public static void read(PrintWriter out ) {
                Criteria crit = new Criteria();
                try{
                        List v = BookPeer.doSelect(crit);
                        out.println("<br> Read seems to work");
                }catch(TorqueException e){
                        System.out.println(e);
                        out.println("<br> Read: "+e);
                }
        }

public static void insert(PrintWriter out ){
                Author bloch = new Author();
                bloch.setFirstName("testing " + System.currentTimeMillis());
                bloch.setLastName("name");
              try{
                AuthorPeer.doInsert(bloch);
                  out.println("<br> Insert seems to work");
              }catch(Exception e){
                        System.out.println(e);
                        out.println("<br> Insert: "+e);
                }
                
        }

When I run the same methods (using the same torque.properties) from within a
servlet (all the jar files in the shared lib folder of the server), I get
Exceptions...

- The Torque.isInit() works fine and returns 'true'
- But the read and insert tests both return:
'org.apache.torque.TorqueException: Could not retrieve connection info from
pool'
- If I use the Author.save() method instead of the
AuthorPeer.doInsert(Author), I get a NullPointerException

Does somebody know what I'm doing wrong? I'm really a newbie on the Tomcat
server, so it could be something quite basic... maybe...

Thanks again for your help!
Christian



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

Reply via email to