Hello!

I'm trying to connect to the database using JDBC and cocoon.xconf.

 

import java.sql.*;

import java.util.*;

 

import javax.sql.DataSource;

 

import org.apache.avalon.framework.component.ComponentException;

import org.apache.avalon.framework.component.ComponentManager;

import org.apache.avalon.framework.component.ComponentSelector;

import org.apache.avalon.framework.component.Composable;

import org.apache.avalon.excalibur.datasource.DataSourceComponent;

 

public class jdbcTest implements Composable{

                

                DataSourceComponent datasource = null;

                

                public void compose(ComponentManager manager) throws
ComponentException {

                               ComponentSelector dbselector =

            (ComponentSelector) manager.lookup(DataSourceComponent.ROLE +
"Selector");

        datasource = (DataSourceComponent) dbselector.select("oracle_db");
//name as defined in cocoon.xconf

        try {

                                               Connection conn =
datasource.getConnection();

                               } catch (SQLException e) {

                                               e.printStackTrace();

                               }

                }

 

 

                public static void main(String[] args)  {

                               

                //////

                               

                }

                

 

}

 

How to use compose( ) function in main() ???

 

Reply via email to