Hi, I tried to coonect to a apache derby server using the DBManager class
which is attached in the mail. I get the following error.

 

[2008-06-30 10:52:03,091] ERROR com.bupa.bqpmonitor.quartz.job.BQPHttpJob
Insuff

icient data while reading from the network - expected a minimum of 6 bytes
and r

eceived only -1 bytes.  The connection has been terminated.

java.sql.SQLException: Insufficient data while reading from the network -
expect

ed a minimum of 6 bytes and received only -1 bytes.  The connection has been
ter

minated.

        at
org.apache.derby.client.am.SQLExceptionFactory.getSQLException(Unknow

n Source)

        at org.apache.derby.client.am.SqlException.getSQLException(Unknown
Sourc

e)

        at org.apache.derby.jdbc.ClientDriver.connect(Unknown Source)

        at java.sql.DriverManager.getConnection(DriverManager.java:525)

        at java.sql.DriverManager.getConnection(DriverManager.java:193)

        at
com.bupa.bqpmonitor.applite.utils.DBManager.getConnection(DBManager.j

ava:88)

        at
com.bupa.bqpmonitor.appservice.dataaccess.dao.log.MonitorLogDAO.inser

tLog(MonitorLogDAO.java:95)

 

It is a simple Web application trying to insert data in the derby database,
using the MonitorLogDao class.

I have done the following settings in server.xml placed in the following
directory structure D:\jakarta-tomcat-3.3.2\conf

Please let me know if I need to make any additional settings or if my
settings are incorrect.

 

 

Thanks and regards

Anil D'souza

Patni Computer Systems Ltd.
Building No.II, Sector No.2
Millennium Business Park, Mahape
Navi Mumbai 400 710.
Tel : +91 22 2778 3600 Ext: 2248

 

Attachment: DBManager.java
Description: Binary data

Attachment: MonitorLogDAO.java
Description: Binary data

<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
   Copyright 1999-2004 The Apache Software Foundation
 
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
 
       http://www.apache.org/licenses/LICENSE-2.0
 
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
-->
<Server>

    <!-- You can add a "home" attribute to represent the "base" for 
         all relative paths. If none is set, the TOMCAT_HOME property
         will be used, and if not set "." will be used.
         webapps/, work/ and log/ will be relative to this ( unless 
         set explicitely to absolute paths ).
      -->
    <ContextManager workDir="work" >

      <!-- ==================== Global modules ==================== -->
        <LoaderInterceptor11  useApplicationLoader="true" />

        <TrustedLoader />

        <LogSetter name="tc_log" timestamps="true"
		   verbosityLevel="INFORMATION"  />

        <LogEvents enabled="false" />
        
        <!-- Backward compat: read the Context declarations from server.xml-->
        <ContextXmlReader config="conf/server.xml" />

        <!-- Separated Context -->
        <ContextXmlReader config="conf/apps.xml" />

        <AutoDeploy source="modules" target="modules" 
		    redeploy="true" />

        <AutoWebApp dir="modules" host="DEFAULT" trusted="true"/>

        <AutoDeploy source="webapps" target="webapps" />

        <AutoWebApp dir="webapps" host="DEFAULT" />

        <PolicyLoader securityManagerClass="java.lang.SecurityManager"
		      policyFile="conf/tomcat.policy" />

        <SimpleMapper1 />

        <SessionExpirer checkInterval="60" />
        <!-- For development you can use randomClass="java.util.Random" -->
        <SessionIdGenerator randomClass="java.security.SecureRandom" 
                            randomFile="/dev/urandom" />


        <!-- ========== context processing modules ========== -->

        <!-- This will be the "default" profile 
             ( all except the "global" modules can be set per context )
          -->
        <LogSetter name="servlet_log" 
		   timestamps="true"
		   verbosityLevel = "INFORMATION"
		   path="logs/servlet-${yyyyMMdd}.log" 
		   />

        <LogSetter  name="JASPER_LOG"
		   timestamps="true" 
		   path="logs/jasper-${yyyyMMdd}.log" 
		   verbosityLevel = "INFORMATION"  />

        <WebXmlReader validate="true" />

        <ErrorHandler showDebugInfo="true" />

        <WorkDirSetup cleanWorkDir="false" />

        <Jdk12Interceptor /> 

        <!-- Non-standard invoker, for backward compat. ( /servlet/* ) -->
        <InvokerInterceptor /> 

        <!-- you can add javaCompiler="jikes" -->
        <JspInterceptor keepGenerated="true"
			largeFile="false"
			useJspServlet="false"
			/>
        
        <StaticInterceptor listings="true"
                           useAcceptLanguage="true"
                           useCharset="locale" />
        
        <ReloadInterceptor fullReload="true" />

        <SimpleSessionStore maxActiveSessions="-1" />

        <AccessInterceptor />

        <CredentialsInterceptor />

        <SimpleRealm  filename="conf/users/global-users.xml" />

       <!-- UnComment the following and comment out the
            above to get a JDBC realm.
            Other options for driverName: 
              driverName="oracle.jdbc.driver.OracleDriver"
              connectionURL="jdbc:oracle:thin:@ntserver:1521:ORCL"
              connectionName="scott"
              connectionPassword="tiger"

              driverName="org.gjt.mm.mysql.Driver"
              connectionURL="jdbc:mysql://localhost/authority"
              connectionName="test"
              connectionPassword="test"

            "connectionName" and "connectionPassword" are optional.
        -->
        <!--
        <JDBCRealm
            debug="99" 
	    driverName="sun.jdbc.odbc.JdbcOdbcDriver" 
	    connectionURL="jdbc:odbc:TOMCAT" 
	    userTable="users" 
            userNameCol="user_name" 
            userCredCol="user_pass" 
	    userRoleTable="user_roles" 
            roleNameCol="role_name" />
        -->

        <LoadOnStartupInterceptor />

        <Servlet22Interceptor />


        <!-- Tag pooling support.
             To enable the reuse of tag handlers as described in
             the JSP spec, uncomment the following.  If your pages
             use a lot of custom tags, you should see a nice performance
             gain.
             
             Note that placing the interceptor here will enable
             Tag pooling for all of the web applicatitions loaded -
             this may be a bad thing if all tags are not coded to
             handle reuse. To enable pooling only for specific web
             applications i.e. Contexts, place the interceptor inside of 
             the Context's definition.
             
             To view information about tag usage uncomment the tag
             LogSetter. Set verbosityLevel to DEBUG to see everytime
             a tag is obtained and released.
        -->
        <!--
        <LogSetter  name="tag_pool_log" timestamps="true" 
            path="logs/tagpool-${yyyyMMdd}.log" 
            verbosityLevel="INFORMATION" />

        <TagPoolManagerInterceptor />
        -->

        <!-- Request processing -->

        <DecodeInterceptor /> 

        <!-- If you are running SSL and wish to verify Tomcat sessions 
             against SSL sessions, use checkSSLSessionId="true"
             Default is checkSSLSessionId="false" -->
        <SessionId cookiesFirst="true" noCookies="false" /> 

        <!-- Automatic config generation
             Set noRoot="false" if you wish to have Tomcat try to take
               control of the external web server's root context.
               Additonal configuration of the external web server may be
               required for this to be successful.
             Note: Configuration files are not written as part of the
               default startup behvior.  Append "jkconf" to the startup
               command to have Tomcat initialize, write the config files,
               then exit. This may be done while Tomcat is running.
          -->
        <ApacheConfig noRoot="true" />
        <IISConfig noRoot="true" />
        <NSConfig noRoot="true" />

         <!-- Uncoment for apache-style logs 
              Attributes: logFile, flush, format
        <AccessLogInterceptor/>
          -->
      <!-- ==================== Connectors ==================== -->

       <!-- old http adapter. Attributes:
               secure - use SSL ( https )
               keystore, keypass - certs for SSL
               port 
               reportedname - Server name to send back to browser
                              by default report Tomcat Web Server ...
                              set an empty string to avoid sending server header 
        -->
        <!-- Uncomment this if useing a 1.1 JDK
        <Http10Connector   port="8080" 
			   secure="false"
			   maxThreads="100"
			   maxSpareThreads="50"
			   minSpareThreads="10" />
        -->
        <!--
            Uncomment this for SSL support. You _need_ to set up a
            server certificate if you want this to work, and you
            need JSSE. See tomcat-ssl-howto.html for more detailed
            instructions.

            1. Make the JSSE jars available to Tomcat, either by making
               them an installed extension or by adding them to the
               Tomcat CLASSPATH.
            2. Do: keytool -genkey -alias tomcat -keyalg RSA
               RSA is essential to work with Netscape and IIS.
               Use "changeit" as password. ( or add keypass attribute )
               You don't need to sign the certificate.
         -->
        <!--
        <Http10Connector  port="8443" secure="true" />
        -->

        <!--
	    HTTP 1.1 support using the Coyote adapter and
	    and Http11 processor from jakarta-tomcat-connectors.

	    Note: CoyoteConnector supports the same attributes as
	          Http10Connector
  	    -->
	 
        <CoyoteConnector   port="8080" 
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false"  acceptCount="100"
               debug="0" connectionTimeout="20000" 
               disableUploadTimeout="true" />

	    <!-- Note : To disable connection timeouts, set connectionTimeout value
	     to -1 -->
		
		<!-- Note : To use gzip compression you could set the following properties :
		
				   compression="on" 
				   compressionMinSize="2048" 
				   noCompressionUserAgents="gozilla, traviata" 
				   compressableMimeType="text/html,text/xml"
		-->

        <!--
             JNI connector. It assumes the library is located in 
             TOMCAT_HOME/bin/native/jni_connect.[dll, nlm, so]. or in LD_LIBRARY_PATH.
             For different paths set "nativeLibrary" parameter.

             The JniConnector will be self-enable only if JNI mode is detected.
         -->
        <JniConnector /> 


        <!-- Apache AJP12 support. This is also used to shut down tomcat.
             Parameter "address" defines network interface this Interceptor
             "binds" to. Add it if you want to "bind" to just "127.0.0.1".
             
             address="127.0.0.1"
             
             Parameter "tomcatAuthentication", controls if Tomcat honors 
             ( and uses ) auth done in HTTP Server or not, when true Tomcat does 
             not use in any way auth information provided by the HTTP Server. 
             true is the default. 
             
             tomcatAuthentication="false"
             
          -->
        <Ajp12Connector	 port="8007" />

        <!-- Apache AJP13 support (mod_jk)
             Parameter "address" defines network interface this Interceptor
             "binds" to. Add it if you want to "bind" to just "127.0.0.1".

             address="127.0.0.1"

             Parameter "tomcatAuthentication", controls if Tomcat honors 
             ( and uses ) auth done in HTTP Server or not, when true Tomcat does 
             not use in any way auth information provided by the HTTP Server. 
             true is the default. 
             
             tomcatAuthentication="false"
          -->
        <!-- old JK support.  Uncomment if you need to use a 1.1 JDK     
        <Ajp13Connector port="8009" />
	-->

        <!-- Jk2 support using coyote.    -->
        <CoyoteConnector processorClassName="org.apache.jk.server.JkCoyoteHandler" 
                          port="8009" />

      <!-- 
           Context definitions can be placed here ( not recommended ) or 
           in separate files. The ContextXmlReader will read all context
           definitions ( you can customize the "base" filename ). 
 
           The default is conf/apps-[name].xml.
 
           See conf/apps-examples.xml and conf/apps-admin.xml  
       -->

    <Logger className="org.apache.catalina.logger.FileLogger"
             prefix="localhost_DBTest_log." suffix=".txt"
             timestamp="true"/>

  <Resource name="jdbc/TestDB"
               auth="Container"
               type="javax.sql.DataSource"/>

  <ResourceParams name="jdbc/BQPDataSource">
    <parameter>
      <name>factory</name>
      <value>org.apache.commons.dbcp.BasicDataSourceFactory</value>
    </parameter>

    <!-- Maximum number of dB connections in pool. Make sure you
         configure your mysqld max_connections large enough to handle
         all of your db connections. Set to 0 for no limit.
         -->
    <parameter>
      <name>maxActive</name>
      <value>100</value>
    </parameter>

    <!-- Maximum number of idle dB connections to retain in pool.
         Set to 0 for no limit.
         -->
    <parameter>
      <name>maxIdle</name>
      <value>30</value>
    </parameter>

    <!-- Maximum time to wait for a dB connection to become available
         in ms, in this example 10 seconds. An Exception is thrown if
         this timeout is exceeded.  Set to -1 to wait indefinitely.
         -->
    <parameter>
      <name>maxWait</name>
      <value>10000</value>
    </parameter>

    <!-- MySQL dB username and password for dB connections  
    <parameter>
     <name>username</name>
     <value>javauser</value>
    </parameter>
    <parameter>
     <name>password</name>
     <value>javadude</value>
    </parameter>-->

    <!-- Class name for mm.apacheDerby JDBC driver -->
    <parameter>
       <name>driverClassName</name>
       <value>org.apache.derby.jdbc.ClientDriver</value>
    </parameter>

    <!-- The JDBC connection url for connecting to your MySQL dB.
         The autoReconnect=true argument to the url makes sure that the
         mm.mysql JDBC Driver will automatically reconnect if mysqld closed the
         connection.  mysqld by default closes idle connections after 8 hours.
         -->
    <parameter>
      <name>url</name>
      <value>jdbc:derby://localhost:8080/firstdb?create=false</value>
    </parameter>
  </ResourceParams>

    </ContextManager>
</Server>

Reply via email to