cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kelly Cole" <KellyC...@Freightliner.com>
Subject Connection problem to DB2
Date Thu, 16 May 2002 19:50:16 GMT
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: <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail: <cocoon-users-help@xml.apache.org>


Mime
View raw message