Hi All,
I face a problem to get database connection in Action, i followed all the step in
the cocoon2
documentation ( section Using Databases ), the example is not very complete( included
below ).
Do you know how to solve this problem, please tell me ....
********************************** Example From Cocoon2
*************************************
import org.apache.avalon.ComponentManager;
import org.apache.avalon.ComponentSelector;
import org.apache.cocoon.Roles;
import org.apache.cocoon.component.datasource.DataSourceComponent;
import java.sql.Connection;
// .... Skip a lot of lines until we are in the method you use
// to initialize the DataSourceComponent ....
private DataSourceComponent datasource;
public void compose(ComponentManager manager) {
ComponentSelector selector = (ComponentSelector)
manager.lookup(Roles.DB_CONNECTION);
this.datasource = (DataSourceComponent) selector.select("MyConnectionName");
}
// .... Skip more lines until we actually need to use the datasource
private void meMethod() {
Connection myConnection = this.datasource.getConnection();
// .... perform SQL code here
myConnection.close();
}
********************************** End Example From Cocoon2
************************************
Thank you.
KOk Choon.
--------------------------------------------------------
Name: Ling Kok Choon
E-mail: Ling Kok Choon <[EMAIL PROTECTED]>
Date: 08/07/01
Time: 16:49:32
This message was sent by Z-Mail Pro - from NetManage
NetManage - delivers Standards Based IntraNet Solutions
--------------------------------------------------------
---------------------------------------------------------------------
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: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>