Alright, I have solved part of my problem by changing from the Torque dbcp to a jndi DataSource made available by Tomcat.
My Torque.properties now looks like this: ########## torque.database.default = bookstore torque.database.bookstore.adapter = mysql torque.dsfactory.bookstore.factory = org.apache.torque.dsfactory.JndiDataSourceFactory torque.dsfactory.bookstore.jndi.path = java:comp/env/jdbc/bookstore ########## I've configured everything according to the JndiDataSourceFactory section on: http://db.apache.org/torque/configuration-howto.html Now, the read test where I do a simple SELECT from the database works. But the doInsert() still returns a NullPointerException (not even caught). Here's the exception: java.lang.NullPointerException org.apache.torque.util.BasePeer.doInsert(BasePeer.java:697) org.apache.torque.util.BasePeer.doInsert(BasePeer.java:639) org.christian.om.BaseAuthorPeer.doInsert(BaseAuthorPeer.java:211) org.christian.om.BaseAuthorPeer.doInsert(BaseAuthorPeer.java:185) org.christian.om.BaseAuthorPeer.doInsert(BaseAuthorPeer.java:522) dbcon.insert(dbcon.java:76) dbcon.doGet(dbcon.java:138) javax.servlet.http.HttpServlet.service(HttpServlet.java:743) javax.servlet.http.HttpServlet.service(HttpServlet.java:856) What could be the cause for that? If I request a connection "Manually" from the pool and then perform an Insert Query on the same database it works fine. So the DataSource settings (read/write right of the user I use etc.) seem to work! Thank you for your Help! Christian -----Urspr�ngliche Nachricht----- Von: Christian Zeidler [mailto:[EMAIL PROTECTED] Gesendet: 06 May 2004 15:41 An: [EMAIL PROTECTED] Betreff: Torque and Tomcat - connection pool Exception 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
