You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Kelly Cole <Ke...@Freightliner.com> on 2002/05/16 21:50:16 UTC

Connection problem to DB2

I am a new user to Cocoon, just trying to test drive it... One of the things
I would like to do is to connect to our database (db2 on os390 connecting
via DB2/Connect). Unfortunately, I get this entry in the sitemap.log:

DEBUG   (2002-05-16) 10:51.03:468
[sitemap.transformer.sql](/cocoon/db/test.html)
HttpProcessor[8080][4]/SQLTransformer$Query: SQLTransformer$Query: could not
acquire a Connection -- waiting 5000 ms to try again.

My cocoon.xconf <datasources> element contains:
	<datasources>
		<jdbc name="TDB2">
			<pool-controller min="1" max="10"/>
			<dburl>jdbc:db2:tdb2</dburl>
			<user>jftl206</user>
			<password>********</password>
		</jdbc>
		<jdbc logger="core.datasources.personnel" name="personnel">
			<pool-controller max="10" min="5"/>
			<dburl>jdbc:hsqldb:hsql://localhost:9002</dburl>
			<user>sa</user>
			<password/>
		</jdbc>
	</datasources>

My web.xml init-param looks like:
		<init-param>
			<param-name>load-class</param-name>
			<param-value>
		COM.ibm.db2.jdbc.app.DB2Driver org.hsqldb.jdbcDriver

			</param-value>
		</init-param>

My sitemap pipeline looks like:
		<map:pipeline>
			<map:match pattern="db/*.html">
				<map:generate src="dev/sql-page.xml"/>
				<map:transform type="sql">
					<map:parameter name="use-connection"
value="TDB2"/>
				</map:transform>
				<map:transform
src="stylesheets/simple-sql2html.xsl"/>
				<map:serialize/>
			</map:match>
		</map:pipeline>

I wrote (well, someone gave it to me) the following Java program to prove
that I can connect to the database from Java from my machine...

import java.sql.*;

class Dynamic 
{   static
    {   try
        {   Class.forName ("COM.ibm.db2.jdbc.app.DB2Driver").newInstance ();
        }
        catch (Exception e)
        {   System.out.println ("\n  Error loading DB2 Driver...\n");
            System.out.println (e);
            System.exit(1);
        }
    }

    public static void main(String argv[])
    {   try 
        {   System.out.println ("  Java Dynamic Sample");
            // Connect to Sample database
   
            Connection con = null;
            // URL is jdbc:db2:dbname
            String url = "jdbc:db2:tdb2";

            if (argv.length == 0) 
            {   // connect with default id/password
                con = DriverManager.getConnection(url);
            }
            else if (argv.length == 2)
            {   String userid = argv[0];
                String passwd = argv[1];
 
                // connect with user-provided username and password
                con = DriverManager.getConnection(url, userid, passwd);
            }
            else 
            {   throw new Exception("\nUsage: java Dynamic [username
password]\n");
            } 

            // Enable transactions
            con.setAutoCommit(false);

            // Perform dynamic SQL SELECT using JDBC
            try
            {   PreparedStatement pstmt1 = con.prepareStatement(
                   "SELECT creator, name FROM sysibm.systables " +
                   "WHERE name = ? " +
                   "ORDER BY 1"); 
                // set cursor name for the positioned update statement
                pstmt1.setCursorName("c1");                                
                pstmt1.setString(1, "SYSGRPS"); 
                ResultSet rs = pstmt1.executeQuery();                       

                System.out.print("\n");
                while( rs.next() )                                         
                {   String tableName = rs.getString("name");
                    System.out.println("Table = " + tableName);
                };
 
                rs.close();                                              
                pstmt1.close();                                             
            }
            catch( Exception e )
            {   throw e; 
            } 
            finally
            {   // Rollback the transaction
                System.out.println("\nRollback the transaction...");
                con.rollback();
                System.out.println("Rollback done.");
            }
        } 
        catch( Exception e )
        {   System.out.println(e);
        } 
    }
}

Note that I am new to Java as well as Cocoon. I think Cocoon is the coolest
framework I've ever seen (since I prefer doing all of my coding in
xml/xslt...).

Any help/pointers would be GREATLY APPRECIATED!!! Also, I have tested that
all of the samples work on my machine (except the JSP, which I think I saw
in the faq that I need to do something to get that going anyway)...

Thanks,
Kelly


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: Connection problem to DB2

Posted by Christian Haul <ha...@dvs1.informatik.tu-darmstadt.de>.
On 16.May.2002 -- 12:50 PM, Kelly Cole wrote:
> I am a new user to Cocoon, just trying to test drive it... One of the things
> I would like to do is to connect to our database (db2 on os390 connecting
> via DB2/Connect). Unfortunately, I get this entry in the sitemap.log:

Things you didn't tell us: 
where is your driver located? (should be WEB-INF/lib)

which versions do you use (Cocoon, JDK, Tomcat)?
(should be 2.0.2 or (cvs) 2.0.3 or (cvs) 2.1-dev,
1.3.1_02, and 4.0.1, expect problems with other
versions, solutions were posted oon this list)

Try to find the portion in core.log where the
connection pool is initialized. You need to
associate a logger with the connection for that
(a logger attribute like for the HSQL connection)

	Chris.

-- 
C h r i s t i a n       H a u l
haul@informatik.tu-darmstadt.de
    fingerprint: 99B0 1D9D 7919 644A 4837  7D73 FEF9 6856 335A 9E08

---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>