Problem of Jakarta DBCP

i have been research about Jakarta Commmon DBCP for over a week.
After reading the offical documentation provided by them, i have some questions about it
1.
can a connection fetched from the pool recover after a network crash such as the the line is off or the swither is down?
i know that a pool has many properties, however, can i control them in the code i wrote?
2.
our project must user DBCP in the Driver mode and control it with a JOCL file, but are there some more documentations that can provide more detail introductions to JOCL, including how to define and wirte the tags and so on.
could anybody help me to resolve the questions ablow, thanks in advanced.
ipiszhang from BOCSoft, Beijing, China P.R.
:-)

Looks like tomcat doesn 't support your locale.
Catalina.start: java.util.MissingResourceException: Can't find bundle for base
ame org.apache.coyote.tomcat4.LocalStrings, locale ru_RU
Try changing your computer's locale and see if that helps.
Look here for more information on how resource bundles work:
http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html

Similar Messages

  • Problem with jakarta commons email

    i am using in addition to the javamail libary the jakarta commons libary.
    do anyone of you havee anyxpieriences with this libary??
    here is my code for send a simple mail:
    String host=null;
            SimpleEmail email = new SimpleEmail();
            try {
                 host=DbJdbc.getSetting("SmptHost");
                try {
                    email.setHostName(host);
                    email.addTo(emailadress);
                   email.setFrom("[email protected]");
                    email.setSubject("Ears mail scheduler");
                    email.setMsg("test");
                    email.setAuthentication("test","test");
                    email.send();
                } catch (EmailException eex) {
                LoggerLars.log("[SendMail] : Error" + eex.getMessage(),4);
                throw new Exception(eex.getMessage());
            } catch  (Exception ex) {
                LoggerLars.log("[SendMail] Exception in Sendmail: "+ex.getMessage(),4);  
         }i am working with the bea weblogic 8.1.3 and i get an error that the catch parameter is not an java.lang.throwable.
    so the try/catch construct doesn't work....did anyone got the same problem?? i don't see any programming fault in the code, i simple copied is from the jakarta websites howto.

    problem solved!!!
    i just had to restart bea und to update the libaries!! thx

  • Poi problem

    i have a problem with jakarta POI.
    for (Iterator rows = sheet.rowIterator(); rows.hasNext();) {
                   row = (HSSFRow) rows.next();
                   // I want to check whether this row does contain any data or not ?
                   i tried row!=null to check no data in this row ....but this does not work.
                   can you suggest any alternative ?

    check the number of cells in the row, and the content of each cell.
    I've noticed that it sometimes returns empty rows and/or empty cells in rows when you'd expect to get nothing.
    Whether due to the way Excel writes things or what I've never bothered to investigate in detail.

  • JDBC and JAKARTA TOMCAT 4.01

    Hello,
    I've a problem with Jakarta Tomcat 4.01. With that, I can't access to my DB from a jsp page. However that works with Jakarta Tomcat 3.2.1 and from a simple java program.
    I work with Windows 2k and I've installed tomcat 4.01 service.
    I've reboot several time the service.
    thanks for your help.

    I'm new at this, but when I upgraded from Tomcat 3.x to 4.0.1, I had to change my user DSN within the ODBC icon on the Windows Control panel.
    I highlighed the user DSN, hit the configure button and remapped the path to my database.
    Again, I'm new at this game, but I hope this provides some assistance.
    Bruce

  • Jakarta JSTL conflict

    Hi,
    I have a problem using Jakarta standard tag library along with
    portal's taglibs.
    If I try to include the directive
    <%@ taglib uri=http://jakarta.apache.org/taglibs/c' prefix='c' %> in a
    jsp file that already include webflow, portlet or portal taglib, I get
    an exception at compile time:
    java.lang.NullPointerException
    at antlr.CharBuffer.fill(CharBuffer.java:45)
    at antlr.InputBuffer.LA(InputBuffer.java:82)
    at antlr.CharScanner.LA(CharScanner.java:147)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.nextToken(JSP2XMLLexer.java:343)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.parse(JSP2XMLLexer.java:296)
    at weblogic.servlet.jsp.jsp2xml.Jsp2XmlOutputter.getSubLexerXmlOutput(Jsp2XmlOutputter.java:277)
    at weblogic.servlet.jsp.jsp2xml.Jsp2XmlOutputter.addIncludeDirective(Jsp2XmlOutputter.java:136)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.addIncludeDirective(JSP2XMLLexer.java:177)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.mINCLUDE_DIRECTIVE(JSP2XMLLexer.java:1076)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.mDIRECTIVE(JSP2XMLLexer.java:772)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.mSTANDARD_THING(JSP2XMLLexer.java:503)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.mTOKEN(JSP2XMLLexer.java:440)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.nextToken(JSP2XMLLexer.java:344)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.parse(JSP2XMLLexer.java:296)
    at weblogic.servlet.jsp.StandardTagLib.makeXMLStream(StandardTagLib.java:345)
    at weblogic.servlet.jsp.StandardTagLib.callValidator(StandardTagLib.java:433)
    at weblogic.servlet.jsp.JspParser.callTaglibValidators(JspParser.java:164)
    at weblogic.servlet.jsp.JspParser.doit(JspParser.java:139)
    at weblogic.servlet.jsp.JspParser.parse(JspParser.java:212)
    at weblogic.servlet.jsp.Jsp2Java.outputs(Jsp2Java.java:119)
    at weblogic.utils.compiler.CodeGenerator.generate(CodeGenerator.java:255)
    at weblogic.servlet.jsp.JspStub.compilePage(JspStub.java:352)
    at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:210)
    at weblogic.servlet.jsp.JspStub.checkForReload(JspStub.java:149)
    at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:521)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:351)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:542)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:368)
    at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:120)
    at jsp_servlet._framework.__portlet._jspService(portlet.jsp:84)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:542)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:368)
    at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:120)
    at com.bea.portal.render.servlets.jsp.taglib.RenderTag.renderPortlets(RenderTag.java:172)
    at com.bea.portal.render.servlets.jsp.taglib.RenderTag.doStartTag(RenderTag.java:60)
    at jsp_servlet._framework._layouts._spanningthreecolumn.__template._jspService(template.jsp:7)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:542)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:368)
    at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:120)
    at jsp_servlet._framework.__page._jspService(page.jsp:64)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:542)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:368)
    at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:120)
    at jsp_servlet._framework.__portal._jspService(portal.jsp:19)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.RequestDispatcherImpl$ForwardAction.run(RequestDispatcherImpl.java:341)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:744)
    at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:251)
    at com.bea.portal.appflow.servlets.internal.PortalWebflowServlet.doGet(PortalWebflowServlet.java:176)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.RequestDispatcherImpl$ForwardAction.run(RequestDispatcherImpl.java:341)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:744)
    at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:251)
    at weblogic.servlet.jsp.PageContextImpl.forward(PageContextImpl.java:116)
    at jsp_servlet.__index._jspService(index.jsp:3)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:5412)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:744)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3086)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2544)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    Did somebody already used jstl with portal ?
    Do you have any idea of what's wrong ?
    regards,
    Roland Pellegrin.

    You need another "'" after the uri=
    Roland Pellegrin wrote:
    Hi,
    I have a problem using Jakarta standard tag library along with
    portal's taglibs.
    If I try to include the directive
    <%@ taglib uri=http://jakarta.apache.org/taglibs/c' prefix='c' %> in a
    jsp file that already include webflow, portlet or portal taglib, I get
    an exception at compile time:
    java.lang.NullPointerException
    at antlr.CharBuffer.fill(CharBuffer.java:45)
    at antlr.InputBuffer.LA(InputBuffer.java:82)
    at antlr.CharScanner.LA(CharScanner.java:147)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.nextToken(JSP2XMLLexer.java:343)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.parse(JSP2XMLLexer.java:296)
    at weblogic.servlet.jsp.jsp2xml.Jsp2XmlOutputter.getSubLexerXmlOutput(Jsp2XmlOutputter.java:277)
    at weblogic.servlet.jsp.jsp2xml.Jsp2XmlOutputter.addIncludeDirective(Jsp2XmlOutputter.java:136)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.addIncludeDirective(JSP2XMLLexer.java:177)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.mINCLUDE_DIRECTIVE(JSP2XMLLexer.java:1076)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.mDIRECTIVE(JSP2XMLLexer.java:772)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.mSTANDARD_THING(JSP2XMLLexer.java:503)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.mTOKEN(JSP2XMLLexer.java:440)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.nextToken(JSP2XMLLexer.java:344)
    at weblogic.servlet.jsp.jsp2xml.JSP2XMLLexer.parse(JSP2XMLLexer.java:296)
    at weblogic.servlet.jsp.StandardTagLib.makeXMLStream(StandardTagLib.java:345)
    at weblogic.servlet.jsp.StandardTagLib.callValidator(StandardTagLib.java:433)
    at weblogic.servlet.jsp.JspParser.callTaglibValidators(JspParser.java:164)
    at weblogic.servlet.jsp.JspParser.doit(JspParser.java:139)
    at weblogic.servlet.jsp.JspParser.parse(JspParser.java:212)
    at weblogic.servlet.jsp.Jsp2Java.outputs(Jsp2Java.java:119)
    at weblogic.utils.compiler.CodeGenerator.generate(CodeGenerator.java:255)
    at weblogic.servlet.jsp.JspStub.compilePage(JspStub.java:352)
    at weblogic.servlet.jsp.JspStub.prepareServlet(JspStub.java:210)
    at weblogic.servlet.jsp.JspStub.checkForReload(JspStub.java:149)
    at weblogic.servlet.internal.ServletStubImpl.getServlet(ServletStubImpl.java:521)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:351)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:542)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:368)
    at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:120)
    at jsp_servlet._framework.__portlet._jspService(portlet.jsp:84)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:542)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:368)
    at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:120)
    at com.bea.portal.render.servlets.jsp.taglib.RenderTag.renderPortlets(RenderTag.java:172)
    at com.bea.portal.render.servlets.jsp.taglib.RenderTag.doStartTag(RenderTag.java:60)
    at jsp_servlet._framework._layouts._spanningthreecolumn.__template._jspService(template.jsp:7)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:542)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:368)
    at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:120)
    at jsp_servlet._framework.__page._jspService(page.jsp:64)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:542)
    at weblogic.servlet.internal.RequestDispatcherImpl.include(RequestDispatcherImpl.java:368)
    at weblogic.servlet.jsp.PageContextImpl.include(PageContextImpl.java:120)
    at jsp_servlet._framework.__portal._jspService(portal.jsp:19)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.RequestDispatcherImpl$ForwardAction.run(RequestDispatcherImpl.java:341)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:744)
    at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:251)
    at com.bea.portal.appflow.servlets.internal.PortalWebflowServlet.doGet(PortalWebflowServlet.java:176)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.RequestDispatcherImpl$ForwardAction.run(RequestDispatcherImpl.java:341)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:744)
    at weblogic.servlet.internal.RequestDispatcherImpl.forward(RequestDispatcherImpl.java:251)
    at weblogic.servlet.jsp.PageContextImpl.forward(PageContextImpl.java:116)
    at jsp_servlet.__index._jspService(index.jsp:3)
    at weblogic.servlet.jsp.JspBase.service(JspBase.java:27)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1058)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:401)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:306)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:5412)
    at weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManager.java:744)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3086)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2544)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:153)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:134)
    Did somebody already used jstl with portal ?
    Do you have any idea of what's wrong ?
    regards,
    Roland Pellegrin.

  • Global variable in servlet & DBPooling questions

    Hello guys,
    I used to develop PHP/ASP, and am new to servlet. I have been searching around for a solution ...
    With Php, we can get the reference of a global variable in any classes->functions...
    How do I do this with servlet ?
    And second..I have developed the DB class as below... I set the datasource to be static, so it initializes only once. Is it a good idea? How would you like to improve this class? any comments?
    package shop.database;
    import javax.sql.DataSource;
    import java.sql.*;
    import org.apache.commons.dbcp.BasicDataSource;
    import org.apache.log4j.Logger;
    import shop.admin.exception.GeneralException;
    public class DdManager {
         static protected Logger logger = Logger.getLogger(DdManager.class);
         private String userName = "root";
    private String password = "";
    private String hostName = "jdbc:mysql://localhost:3306/shop";
    private String database="shop";
         static private DataSource ds;     // set this to be static so all threads share the same job in JVM
         private Statement stmt;
         private Connection conn;
         private ResultSet rs;
         private CallableStatement cs;
    public DdManager() {}
    * setup the data source and return it
         public static DataSource getDataSource(
              String sDrvName,
              String sUserName,
              String sPwd,
              String connectURI) {
              BasicDataSource ds = new BasicDataSource();
              ds.setDriverClassName( sDrvName );
              ds.setUsername( sUserName );
              ds.setPassword( sPwd );
              ds.setUrl( connectURI );
              ds.setMaxActive( 15 );
              ds.setMaxIdle( 10 );
              ds.setMaxWait( 10000 ); // 10 seconds
              return ds;
         * static init of the class
         * this class is will be called only once to initialize the DataSource
         static {
              try {
                   Class.forName( "com.mysql.jdbc.Driver" );
                   ds = getDataSource(     "com.mysql.jdbc.Driver",
                                            "root",
                                            "jdbc:mysql://localhost:3306/shop" );
                   if (ds == null) {
                        String msg = "Connection Pool error";
                        logger.error(msg);
                        throw new GeneralException(msg);
                   logger.info("DataSource has been initialized");
              } catch(Exception exception) {
                   logger.error(exception.toString());
                   try {
                        throw new GeneralException(exception.toString());
                   } catch (GeneralException e) {
                        logger.error(e.toString());
         * get the connection from the pool (DataSource)
    public void openConnection() throws GeneralException {
    try {
         BasicDataSource bds = (BasicDataSource) ds;
         logger.info("NumActive: " + bds.getNumActive() + ", " + "NumIdle: " + bds.getNumIdle());
    conn = ds.getConnection();
    logger.info("Connection of " + database + " has been established");
    } catch(Exception exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    * close the connection will actually return the connection to the pool (Must)
    public void closeConnection() throws GeneralException {
         initResource();
    try {
         if (conn != null){
                   conn.close();
                   logger.info("Connection of " + database + " has been closed");
    } catch(SQLException exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    * prepare the calling stmt
    public void prepareProcedure(String callStatement) throws GeneralException {
         initResource();
    try {
         cs = conn.prepareCall(callStatement);
    } catch(SQLException exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    * set the pass-in parameter for "String"
    public void setParameter(int position, String parameter) throws GeneralException {
    try {
         cs.setString(position, parameter);
    } catch(Exception exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    * set the pass-in parameter for "Integer"
    public void setParameter(int position, int parameter) throws GeneralException {
    try {
         cs.setInt(position, parameter);
    } catch(Exception exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    * execute the procedure and return the resultset
    public ResultSet execProcedure() throws GeneralException {
    try {
         rs = cs.executeQuery();
    } catch(SQLException exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    return rs;
    * close the statment and resultset
         private void initResource() throws GeneralException {
         try {
              if(rs != null) {
                   rs.close();
              if(stmt!= null) {
                   stmt.close();
              logger.info("Statement & Resultset have been free");
         } catch(Exception exception) {
         logger.error(exception.toString());
         throw new GeneralException(exception.toString());
    Thanks mates!
    myy

    Thanks Saish,
    Your response is really appreciated. Sorry about that
    as i didnt know there is 'code' formatting button,
    and I will look into the Singleton pattern.
    As I'm still in the learning stage. Therefore, i
    still have a lot of thing do not understand.
    ... use it in a method signature ...What is "a method signature" ?
    A method signature is basically the method's parameters, return value, name and any access or other modifiers. The following is a method signature:
    static final public void main(final String[] args)Between the braces of the method body is the implementation (or as I already alluded to, the method body).
    Consider using an already-developed connection poolimplementation, such as Jakarta Commons DBCP ...
    I'm trying to implement the Jakarta DBCP. Did I go
    into the wrong way?
    Sorry, did not read the imports. Yes, you are. However, I am confused about what you are trying to implement. You have a static method getDataSource(). You also have a static variable 'ds'. Use one or the other. I would be that there are seemingly random errors cropping up based on whether you remember to call getDataSource() or not.
    You do not, generally, want the data source to be static. Multiple threads might use the class. And if there is only a static data source, you will either need to synchronize the methods that use the data source (resulting in a scaling bottleneck) or not synchronize them (which will totally destroy any concept of a logical unit of work or database transaction).
    .. A static datasource, as in your class, can onlysafely be used by one thread at a time, potentially
    introducing scaling bottlenecks (or race conditions)
    in your system ...
    So, you mean there is no need for the DataSource to
    be static ?
    No, in fact, IMO, it should not be. That is why you are pooling. Use instances. The pool will manage the connections and their availabilty for you.
    Why are you throwing GeneralException everywhere?Here's a question: can someone using your class (a
    caller) realistically be expected to handle a
    database exception?
    When there is a database error, I just want to stop
    the process and redirect the user to an error page. I
    will look into the unchecked exceptions. Thanks.
    Unchecked exceptions do not need to be declared in a method signature or caught within the method body. Checked exceptions do. As such, an added benefit is that unchecked exceptions de-clutter your code.
    In your initResources() method, what happens if theclose() on ResultSet throws an exception
    Oh, yes. I'm so stupid.
    Now I only have ...
         private static DataSource ds;     // set this to
    be static so all threads share the same obj in JVM
         private Connection conn;
         private CallableStatement cs;
    private void initResource() throws GeneralException
    n {
         try {
              if(cs != null) {
                   cs.close();
    logger.info("CallableStatement has been
    as been free");
         } catch(Exception exception) {
         logger.error(exception.toString());
    throw new
    throw new GeneralException(exception.toString());
    You still have issues.
    public void initResources() {
       if (rs != null) {
         try { rs.close(); } catch (SQLException ignore) { ignore.printStackTrace(); }
       if (stmt != null) {
         try { stmt.close(); } catch (SQLException ignore) { ignore.printStackTrace(); }
    }Normally, this type of method would not be called initResources() but rather closeResources() or freeResources(). It would be called from within the 'finally' block of another method using the CallableStatement or ResultSet.
    This is really is problem, would you mind to tell me
    how to handle this(close the connection) if the
    close() on either CallableStatement or Resultset
    throws an exception ?
    See above. Simply log the exception (there is usually nothing meaningful you can do if a close() fails, and it is up to you as a developer if this is an error or just a warning). Another option is to 'chain' exceptions. In your own exception, add a method 'addException(Throwable)'. This would add another exception to a List of exceptions. When you print the stack trace, iterate through the chained exceptions to print them all out. One place where I find this useful is rollback() code. If the original SQL statement fails AND the rollback fails, I definitely want to see that rollback() exception as well in my logs.
    The DB thing makes me headache. What I actually
    wanted is a solution for:
    Let say I have a class "HelloAction.class" contains
    the code:
    public ActionForward XXX() {
         DbManager DB = new DBManager();
         ... do some DB thing here...
         SecondClass SC = new SecondClass();
         SC.doSomeOtherDbThing();
         ... do something else...
         ThirdClass TC = new ThirdClass();
         SC.doMoreOtherDbThing();
    }There are some functions in SecondClass.class and
    ThirdClass.class that will need database connection.
    I consider 'global variable' is because I want these
    two classes are able to use the same
    connection(DbManager) from the function -
    ActionForward XXX().
    What is the best way to implement the above situation
    (sharing the same connection in different classes &
    sub-classes?
    I also just realize that the problem of multi-threads
    with these two class variables..
         private Connection conn;
         private CallableStatement cs;Really headache. I really appreciate any comments.
    Thanks.
    - myyPass the Connection or DataSource to each method or constructor. Call commit() or rollback() from the method that created the transaction.
    - Saish

  • DATABASE CONNECTION POOLING

    These are the files can any experts help me..no error iam getting but the data are not entered in to database..why so?Thanks in advance
    Done all those dbcp setting in tomcat.donno whether it may be right:if you know that too please reply me.how to config dbcp in tomcat
    jsp file
    <%@ taglib uri="/tags/struts-bean" prefix="bean" %>
    <%@ taglib uri="/tags/struts-html" prefix="html" %>
    <html:html locale="true">
    <head>
    <title><bean:message key="welcome.title"/></title>
    <html:base/>
    <link rel="stylesheet" href="css/stylesheet.css" type="text/css"></link>
    </head>
    <body bgcolor="white">
    <img src="tiles/img/logo.jpg" class="contentimg1">
    <html:form action="/Address" method="post" onsubmit="return AddressForm(this);" >
    <html:javascript formName="AddressForm" />
    <div class="roof">
    <html:errors/>
    </div>
    <table class="addContent" >
    <tr>
    <td align="center" colspan="2">
                   <font size="4">ADD NEW USER</font></td>
              </tr>
              <tr>
    <td align="left">
    User Authority
    </td>
    <td align="left">
    <html:select property="userAuthority" value="UserAuthority">
    <html:option value="State Manager"></html:option>
    <html:option value="City Manager"></html:option>
    <html:option value="Store Manager"></html:option>
    <html:option value="Store User"></html:option>
    </html:select>
    </td>
    </tr>
    <tr>
    <td align="right">
    State
    </td>
    <td align="left">
    <html:text property="state" size="30" maxlength="30"/>
    </td>
    </tr>
    <tr>
    <td align="right">
    City
    </td>
    <td align="left">
    <html:text property="city" size="30" maxlength="30"/>
    </td>
    </tr>
              <tr>
    <td align="right">
    <html:submit>Submit</html:submit>
    </td>
    <td> </td>
    </tr>
    </table>
    </html:form>
    </body>
    </html:html>
    ========
    actionclass
    package com.Reliance.struts.Action;
    * @author Raja;
    import java.sql.*;
    import java.util.ArrayList;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import javax.sql.DataSource;
    import org.apache.struts.action.Action;
    import org.apache.struts.action.ActionForm;
    import org.apache.struts.action.ActionForward;
    import org.apache.struts.action.ActionMapping;
    import org.apache.struts.action.ActionMessages;
    import com.Reliance.struts.form.AddressForm;
    import com.Reliance.struts.Dao.dbServiceComponent;
    public class AddressAction extends Action
         public ActionForward execute(
              ActionMapping mapping,
              ActionForm form,
              HttpServletRequest request,
              HttpServletResponse response) throws Exception{
              String done=null;
              dbServiceComponent objdbServiceComponent =null;
         //     String strUserAuthority=objAddressForm.getUserAuthority();
              //String strEmailAddress=objAddressForm.getEmailAddress();
              String query="INSERT INTO ADD_USER(STATE,CITY) VALUES (?,?)";
              boolean add=false;
              DataSource DataSource = null;
              try{
                        AddressForm objAddressForm =(AddressForm)form;
                   HttpSession mySession = request.getSession(false);
         ActionMessages myActionMessages = new ActionMessages();
         DataSource = (DataSource)getDataSource(request, "IMS:IDEA");
         objdbServiceComponent = new dbServiceComponent(DataSource);
         System.out.println("address.objdbservice");
              String strAddressState = objAddressForm.getState();
              String strAddressCity = objAddressForm.getCity();
                   ArrayList queryArgumentList = new ArrayList();
                   System.out.println("array");
    queryArgumentList.add(strAddressState);
    queryArgumentList.add(strAddressCity);
              System.out.println("array2");
    add=objdbServiceComponent.addUser(query, queryArgumentList);
    System.out.println("addreturn");
              catch(Exception e){
                   System.out.println("address action");
                   System.out.println(e.getMessage());
    if(add)
         done="success";
    else
         done="failure";
              return mapping.findForward(done);
    =============
    action form
    package com.Reliance.struts.form;
    import javax.servlet.http.HttpServletRequest;
    import org.apache.struts.action.*;
    * @author Raja.A
    * Form bean for the Address Entry Screen.
    public class AddressForm extends ActionForm
         private String state=null;
         private String city=null;
         private String userAuthority=null;
              public void setUserAuthority(String userAuthority){
              this.userAuthority=userAuthority;
         public String getUserAuthority(){
              return this.userAuthority;
         public void setState(String state){
              this.state=state;
         public String getState(){
              return this.state;
         public void setCity(String city){
              this.city=city;
         public String getCity(){
              return this.city;
    * Reset all properties to their default values.
    * @param mapping The mapping used to select this instance
    * @param request The servlet request we are processing
    public void reset(ActionMapping mapping, HttpServletRequest request) {
              this.state=null;
              this.city=null;
    * Reset all properties to their default values.
    * @param mapping The mapping used to select this instance
    * @param request The servlet request we are processing
         * @return errors
         public ActionErrors validate(
                   ActionMapping mapping, HttpServletRequest request ) {
                   ActionErrors errors = new ActionErrors();
                   if( getUserAuthority() == null || getUserAuthority().length() < 1 ) {
                        errors.add("userAuthority",new ActionMessage("error.userAuthority.required"));
                   if( getState() == null || getState().length() < 1 ) {
                        errors.add("State",new ActionMessage("error.state.required"));
                   if( getCity() == null || getCity().length() < 1 ) {
                        errors.add("City",new ActionMessage("error.city.required"));
                   return errors;
    ==============
    dbcomponent
    package com.Reliance.struts.Dao;
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.util.ArrayList;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.sql.DataSource;
    public class dbServiceComponent{
    public Connection conn = null;
         * declared as private inorder to avoid it to create an instance of this
         * class.
         protected dbServiceComponent() {
         * This constructor initializes the class object dataSource with reference
         * datasource as object
         * @param ds
         public dbServiceComponent(DataSource Datasource) throws Exception {
         if (conn == null) {
         try {
              Context initContext = new InitialContext();
              Context envContext = (Context)initContext.lookup("java:/comp/env");
              ds = (DataSource)envContext.lookup("jdbc/RILDB");
              System.out.println(ds);
              conn = ds.getConnection();
              System.out.println("final");
              /* ADDED BY RAJA MAY 08 */
              Context context = new InitialContext();
         if (context == null ) { throw new Exception("Boom - No Context"); }
         Datasource = (DataSource)context.lookup("java:comp/env/jdbc/RILDB");
         if (Datasource == null ) { throw new Exception("Boom - No DataSource"); }
         System.out.println("here");
         conn=Datasource.getConnection();
         System.out.println("conn printing");
         //con = ds.getConnection();
         conn.setAutoCommit(false);
         } catch (SQLException sqlEx) {
         System.out.println("Exception while creating connection in "
         + "constructor com.Reliance.struts.dao.dbServicecomponent."
         + "DBServiceComponent(DataSource ds)");
         System.out.println(sqlEx);
         public boolean addUser (String query,ArrayList argsList) throws SQLException {
              boolean result=false;
              PreparedStatement pstmt=null;
         ResultSet rs = null;
         try {
         System.out.println("dbse-prp1");
              pstmt = conn.prepareStatement(query);
              System.out.println("dbse-prp2");
                             for (int index = 0; index < argsList.size(); index++) {
         pstmt.setString(index + 1, (String) argsList.get(index));
         System.out.println("dbse-prp3");
                             System.out.println("try");
         rs = pstmt.executeQuery();
         System.out.println("execut");
         result=true;
         if (rs.next()) {
              System.out.println("if");
              result=true;
              if(rs.getString(1)=="dbcp"){
                   System.out.println("rs-check");
         result = true;
         } catch (Exception ex) {
              System.out.println("dbservice.adduser.first");
         System.out.println("ex.toString() = " + ex.getMessage());
         finally {
         try {
         if (rs != null) {
         rs.close();
         if (pstmt != null) {
         pstmt.close();
         } catch (SQLException se) {
         System.out.println("Query is " + query);
         System.out.println("Exception while closing PrepareStatement in "
         + "com.Reliance.daoDBServiceComponent."
         + "addUser (String query,ArrayList argsList)" + se.getMessage());
         return result;
    =========
    struts-config
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <!DOCTYPE struts-config PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
    "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
    <!--
    This is a blank Struts configuration file with an example
    welcome action/page and other commented sample elements.
    Tiles and the Struts Validator are configured using the factory defaults
    and are ready-to-use.
    NOTE: If you have a generator tool to create the corresponding Java classes
    for you, you could include the details in the "form-bean" declarations.
    Otherwise, you would only define the "form-bean" element itself, with the
    corresponding "name" and "type" attributes, as shown here.
    -->
    <struts-config>
    <!-- ============================================ Data Source Configuration -->
    <data-sources>
    <data-source key="IMS:IDEA" type="org.apache.commons.dbcp.BasicDataSource">
    <set-property property="driverClassName" value="oracle.jdbc.driver.OracleDriver"/>
    <set-property property="url" value="jdbc:oracle:thin:@192.168.1.14:1521:rildb"/>
    <set-property property="username" value="adventity"/>
    <set-property property="password" value="adv_123"/>
    <set-property property="minCount" value="5"/>
    <set-property property="maxActive" value="50"/>
    <set-property property="defaultAutoCommit" value="true"/>
    <set-property property="defaultReadOnly" value="false"/>
    <set-property property="removeAbandoned" value="true"/>
    <set-property property="logAbandoned" value="true"/>
    </data-source>
    </data-sources>
    <!-- ================================================ Form Bean Definitions -->
    <form-beans>
         <form-bean
    name="AddressForm"
    type="com.Reliance.struts.form.AddressForm"/>
    <!-- sample form bean descriptor for an ActionForm
    <form-bean
    name="inputForm"
    type="app.InputForm"/>
    end sample -->
    <!-- sample form bean descriptor for a DynaActionForm
    <form-bean
    name="logonForm"
    type="org.apache.struts.action.DynaActionForm">
    <form-property
    name="username"
    type="java.lang.String"/>
    <form-property
    name="password"
    type="java.lang.String"/>
    </form-bean>
    end sample -->
    </form-beans>
    <!-- ========================================= Global Exception Definitions -->
    <global-exceptions>
    <!-- sample exception handler
    <exception
    key="expired.password"
    type="app.ExpiredPasswordException"
    path="/changePassword.jsp"/>
    end sample -->
    </global-exceptions>
    <!-- =========================================== Global Forward Definitions -->
    <global-forwards>
    <!-- Default forward to "Welcome" action -->
    <!-- Demonstrates using index.jsp to forward -->
    <forward
    name="welcome"
    path="/Welcome.do"/>
    </global-forwards>
    <!-- =========================================== Action Mapping Definitions -->
    <action-mappings>
    <!-- Default "Welcome" action -->
    <!-- Forwards to Welcome.jsp -->
    <action
    path="/Welcome"
    forward="/pages/Welcome.jsp"/>
    <action
    path="/TestAction"
                   type="com.Reliance.struts.Action.TestAction">
    <forward name="testAction" path="/pages/TestAction.jsp"/>
              </action>
    <action
    path="/Address"
                   type="com.Reliance.struts.Action.AddressAction"
    name="AddressForm"
    scope="request"
    validate="true"
    input="/index.jsp">
    <forward name="success" path="tilesdefsuccess"/>
    <forward name="failure" path="tilesdeffailure"/>
              </action>
    <action
    path="/AddressJavascriptValidation"
                   type="com.Reliance.struts.Action.AddressAction"
    name="AddressForm"
    scope="request"
    validate="true"
    input="/pages/AddressJavascriptValidation.jsp">
    <forward name="success" path="/pages/success.jsp"/>
              </action>
    <action
    path="/Tiles/Example"
    forward="Tiles.Example"/>
    <!-- sample input and input submit actions
    <action
    path="/Input"
    type="org.apache.struts.actions.ForwardAction"
    parameter="/pages/Input.jsp"/>
    <action
    path="/InputSubmit"
    type="app.InputAction"
    name="inputForm"
    scope="request"
    validate="true"
    input="/pages/Input.jsp"/>
    <action
    path="/edit*"
    type="app.Edit{1}Action"
    name="inputForm"
    scope="request"
    validate="true"
    input="/pages/Edit{1}.jsp"/>
    end samples -->
    </action-mappings>
    <!-- ============================================= Controller Configuration -->
    <controller
    processorClass="org.apache.struts.tiles.TilesRequestProcessor"/>
    <!-- ======================================== Message Resources Definitions -->
    <message-resources parameter="com.Reliance.struts.properties.MessageResources" />
    <!-- =============================================== Plug Ins Configuration -->
    <!-- ======================================================= Tiles plugin -->
    <!--
    This plugin initialize Tiles definition factory. This later can takes some
         parameters explained here after. The plugin first read parameters from
         web.xml, thenoverload them with parameters defined here. All parameters
         are optional.
    The plugin should be declared in each struts-config file.
    - definitions-config: (optional)
    Specify configuration file names. There can be several comma
              separated file names (default: ?? )
    - moduleAware: (optional - struts1.1)
    Specify if the Tiles definition factory is module aware. If true
    (default), there will be one factory for each Struts module.
                   If false, there will be one common factory for all module. In this
    later case, it is still needed to declare one plugin per module.
    The factory will be initialized with parameters found in the first
    initialized plugin (generally the one associated with the default
    module).
                   true : One factory per module. (default)
                   false : one single shared factory for all modules
         - definitions-parser-validate: (optional)
         Specify if xml parser should validate the Tiles configuration file.
                   true : validate. DTD should be specified in file header (default)
                   false : no validation
         Paths found in Tiles definitions are relative to the main context.
    -->
    <plug-in className="org.apache.struts.tiles.TilesPlugin" >
    <!-- Path to XML definition file -->
    <set-property property="definitions-config"
    value="/WEB-INF/tiles-defs.xml" />
    <!-- Set Module-awareness to true -->
    <set-property property="moduleAware" value="true" />
    </plug-in>
    <!-- =================================================== Validator plugin -->
    <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
    <set-property
    property="pathnames"
    value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
    </plug-in>
    </struts-config>

    Hi,
    Does anybody know where to find examples of using this jakarta dbcp in tomcat servlet?
    I looked at http://jakarta.apache.org/commons/dbcp/ examples but they are all about run the Java class at command line. Where to config the tomcat with JDBC pooling?
    Thanks in advance!
    Icy

  • Help with OracleDataSourceFactory

    I'm trying to setup connection pooling in Tomcat 4.1.24 to use Oracle's JDBC libraries. I've defined (in my web.xml) a <Resource> and <ResourceParams> sections as follows:
    <Resource name="jdbc/Db"
    auth="Container"
    type="oracle.jdbc.pool.OracleConnectionCacheImpl"/>
    <ResourceParams name="jdbc/Db">
    <parameter><name>factory</name>
    <value>oracle.jdbc.pool.OracleDataSourceFactory</value></parameter>
    <!--
    <parameter><name>url</name>
    <value>jdbc:oracle:thin:@200.65.6.188:1521:tiggs9i</value></parameter>
    -->
    <parameter><name>driverType</name>
    <value>thin</value></parameter>
    <parameter><name>serverName</name>
    <value>200.65.6.188</value></parameter>
    <parameter><name>networkProtocol</name>
    <value>tcp</value></parameter>
    <parameter><name>databaseName</name>
    <value>tiggs9i</value></parameter>
    <parameter><name>portNunber</name>
    <value>1521</value></parameter>
    <parameter><name>user</name>
    <value>cmluser</value></parameter>
    <parameter><name>password</name>
    <value>cml</value></parameter>
    <parameter><name>maxLimit</name>
    <value>20</value></parameter>
    <parameter><name>minLimit</name>
    <value>10</value></parameter>
    <parameter><name>cacheScheme</name>
    <value>1</value></parameter>
    </ResourceParams>
    As you can see, I've commented out the URL setting as that wasn't working and replaced it with the driverType through portNumber settings. It still doesn't work. When I do a lookup() on the java:comp/env context for the DataSource I get the following:
    NamingException: User credentials doesn't match the existing ones
    I don't know what that means as I know that the username and password given above are valid.
    I also can't find any useful documentation for OracleDataSourceFactory. Any idea where I should look. It isn't in Oracle9i JDBC Developer's Guide and Reference and a Google search gives nothing useful yet it is a class provided in the classes12.jar JDBC library.
    Any help is appreciated.
    Kevin.

    I've found no documentation to the OracleObjectFactory as well, so it was a bit trial and error.I wonder if this class is 'officially' supported.
    I finally managed to get it work with Tomcat web application deployment descriptors instead of placing it into the server.xml.
    However, the OracleObjectFactory does not support all atributes (CacheInactivityTeimeout, CacheTimeToLiveTimeout, ...) available in OracleConnectionCacheImpl, so you should consider
    to write your own ObjectFactory if required. This is fairly easy, because there are good samples available (Tomcat, Jakarta DBCP, ...)
    <?xml version="1.0" encoding="UTF-8"?>
    <Context debug="0" docBase="xxx.war" path="/xxx"">
    <Resource name="jdbc/xxx" auth="Container" type="oracle.jdbc.pool.OracleConnectionCacheImpl"/>
    <ResourceParams name="jdbc/xxx">
    <parameter>
    <name>factory</name>
    <value>oracle.jdbc.pool.OracleDataSourceFactory</value>
    </parameter>
    <parameter>
    <name>maxLimit</name>
    <value>5</value>
    </parameter>
    <!--
    <parameter>
    <name>cacheScheme</name>
    <value>1=dynamic_scheme or 2=fixed_wait_scheme or 3=fixed_return_null_scheme</value>
    </parameter>
    -->
    <parameter>
    <name>minLimit</name>
    <value>1</value>
    </parameter>
    <parameter>
    <name>maxLimit</name>
    <value>5</value>
    </parameter>
    <parameter>
    <name>url</name>
    <value>jdbc:oracle:thin:@myhost:1526:CCCFIT1</value>
    </parameter>
    <parameter>
    <name>user</name>
    <value>xxxx</value>
    </parameter>
    <parameter>
    <name>password</name>
    <value>xxxx</value>
    </parameter>
    </ResourceParams>
    </Context>
    Here the code snippet to access the DataSource:
    Context ctx = new InitialContext();
    DataSource ds = (DataSource)ctx.lookup( "java:/comp/env/jdbc/xxx");
    Connection connection = ds.getConnection();
    Hope this helps,
    Markus

  • Jsf-1.0 Final Release and tomcat 5.019

    I post again to say that is works well finally.
    To make it works:
    - download jsf-1.0 FR
    - in your application .war put in WEB-INF/lib/: common-digester.jar, jsf-api.jar, jsf-impl.jar, common-beanutils.jar and jstl.jar. (libs of jsf + lib of jsp).
    - dont use in web.xml <listener-class>com.sun.config.configListener<listener-class>
    - put your appli in jakarata.../webapps
    It works without a class extending ServletContextListener (servlet-api.jar).
    If you have problems erase jakarta.../work/Catalina/yourappli and reload.

    Just for my own information : where did you get jstl.jar and standard.jar ?
    I had to dig in the latest nightly snapshot from jstl jakarta web site to find them but I don't even know if the one I use are final releases of not...

  • Printing a word document

    Hi guys,
    How can I print a word document? Is there any examples that I can refering to?
    Thanks

    Hi,
    Jakarta POI can help you to solve your problem
    http://jakarta.apache.org/poi/index.html
    L.P.

  • ClassCastException casting CallableStatement into OracleCallableStatement

    Well, i have configured Jakarta DBCP 1.1 with Jakarta Tomcat 4.1.29, JDK 1.4.2, with a database Oracle 9i over Win32 Platform.
    Everything works fine if i use Statements and make SQL sentences. But when i try to execute a stored procedure with a callable statement, i need to pass it a CLOB parameter, so i need to cast a CallableStatement into a OracleCallableStatement, to use the Oracle Extensions. This process makes a ClassCastException.
    This process works fine without DBCP, using just a connection, but fails when use DBCP connection pool.
    I have tried to cast the Connection into OracleConnection that i get from the pool, but i get the same error. Also I have checked Connection is not null and connection works.
    Could anyone gimme a solution? Thanx for your help!

    Can't you use method getClob from CallableStatement, and then pass the data to the clob using setCharacterStream(...)?
    BTW, I think DBCP wraps the genuine Oracle classes, which is the reason that your objects are not instances of Oracles classes.

  • Java.sql.SQLException: No operations allowed after connection closed

    Hi all
    I was trying the jakarta DBCP pool for managing my connections to Mysql(4.0.17-standard ). I let tomcat to manage the pool by specifying datasource in server.xml and web.xml. Everything works fine if there are only a few transactions. But when the number of queries increse, I get an exception like
    java.sql.SQLException: No operations allowed after connection closed.
    Connection was closed explicitly by the application at the following location:
    ** BEGIN NESTED EXCEPTION **
    java.lang.Throwable
    STACKTRACE:
    java.lang.Throwable
            at com.mysql.jdbc.Connection.close(Connection.java:1061)
            at org.apache.commons.dbcp.PoolableConnection.reallyClose(PoolableConnec
    tion.java:124)
            at org.apache.commons.dbcp.PoolableConnectionFactory.destroyObject(Poola
    bleConnectionFactory.java:196)
            at org.apache.commons.pool.impl.GenericObjectPool.returnObject(Unknown S
    ource)
            at org.apache.commons.dbcp.AbandonedObjectPool.returnObject(AbandonedObj
    ectPool.java:140)
            at org.apache.commons.dbcp.PoolableConnection.close(PoolableConnection.j
    ava:110)
    ......I then tried the Connecion Pool manually with DBCP to check it is a problm with tomcat or ont. Still the exception comes after a few transactions. I re-checked the code and I am closing all connections in finally block. I searched in net for a solution, but couldnt find any. Is that a problm with mysql? has anyone experienced it? Any help will be greatly appreciated
    thanks
    boolee

    Odd that Throwable is the exception logged. What does your finally block actually look like? As an experiment, what happens if you execute the following line of hypothetical code in your 'finally' block?
    finally {
      System.out.println(conn.getClass().getName());
    }- Saish

  • Single connection?

    I got my 1TB time capsule today and went through the setup. I have both a MBP 17 and a MacMini, both intel, both on the latest Leopard. I ran the setup on both and setup both time machine copies to backup. Everything seems to work fine.
    I figured since I have so much space I would also backup a few files to the TC. So on the MBP I connected and copied my VMWare virtual machines over there. I wanted to use my MacMini to copy some other files over but it simply would not connect and reported connection failure no matter what I did, including a reboot of the MacMini.
    After the VM copies were complete on the MBP I ejected the TC drive. I then tried to connect from the MacMini and it connected! I started a copy of the files from the Mini to the TC and now as a test I'm trying to connect to the drive from the MBP...
    And it will not connect. What gives? This seems very odd that a multiple connections cannot be made. Perhaps it is truly not NAS as one might think.
    M

    I cant download anything to my environment due to restrictions so I have do create something in house.I bet your servlet container is already shipped with support for a connection pool, like some of these:
    Jakarta DBCP
    C3P0
    Proxool
    Db Connection Broker
    http://java-source.net/open-source/connection-pools
    Advice: don't reinvent the wheel

  • Monitoring DBCP from Jakarta Commons

    Jakarta Commons DBCP works fairly well for our projects, but is there an easy way to monitor the status of the connections in the pool
    real-time?
    any help greatly appreciated.

    yes i have read them many times...Problem is here...
    One example of dbcp writes directly the sql query referencing to the datasource which we have configured in server.xml without using the dbcp.jar file
    Other example of dbcp is longer. Creating pooled connection usind dbcp.jar libraries....etc...
    these were just examples...every example is different than the other so my mind mixed...

  • Oracle connection pool problem (dbcp binded with  jtom)

    Hi,
    my webserver is Tomcat5.0.18, I want to offer the connection pool and transaction management
    in my currently system
    I know in Tomcat5.0 version, we can use the DBCP to offer the database connection pool
    service, to apply the transaction management in my system, I adapt the JTOM
    now, my problem is
    to use DBCP, I setup the datasource factory to be
    org.apache.commons.dbcp.BasicDataSourceFactory, the connection pool is ok, but
    the transaction management offerred by JTOM will failure
    to make the tranaction management of JTOM succeed, I have to setup the datasource factory to be
    org.objectweb.jndi.DataSourceFactory, but the connection pool offerred by Tomcat will failure now
    it seems that these two datasource factory has conflict
    How can I do?, I don't want to use the connection pool offerred in JTOM
    Anyone can help me??
    Thanks in advance

    Hi,
    I don't know the solution for JOTM, but you could try this JTA and its connection pools:
    http://www.atomikos.com ships a JTA that integrates with Tomcat and also provides JDBC connection pooling. There is a GUI control panel so that you don't have to know the XML details for Tomcat's config files.
    Best,
    Guy

Maybe you are looking for