tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "sam wun" <sw2...@gmx.com>
Subject Re: Re: Can't execute servlet project
Date Tue, 02 Sep 2008 15:55:27 GMT
This is the only context.xml file I got in the tomcat (5.5.26) directory:

/tomcat/apache-tomcat-5.5.26/conf/context.xml:



<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You 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.
-->
<!-- The contents of this file will be loaded for each web application -->
<Context>

    <!-- Default set of monitored resources -->
    <WatchedResource>WEB-INF/web.xml</WatchedResource>

    <!-- Uncomment this to disable session persistence across Tomcat 
restarts -->
    <!--
    <Manager pathname="" />
    -->

</Context>


> ----- Original Message -----
> From: David Smith
> Sent: 03/09/08 01:49 am
> To: Tomcat Users List
> Subject: Re: Can't execute servlet project
> 
> DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: 
> Cannot create JDBC driver of class '' for connect URL 'null'"
> 
> This error typically indicates the JNDI db pool hasn't been setup 
> correctly.  Some config option isn't setup.  What's in this webapp's 
> context xml file?  Also what's in it's WEB-INF/web.xml?  Lastly, you 
> should have your database driver jar file in tomcat's common/lib (for 
> tomcat v 5.5) or /lib (tomcat v 6). 
> 
> You can also take a look at tomcat's JDBC Datasource howto's on the 
> tomcat website for your version of tomcat which offer a lot of help.
> 
> --David
> 
> sam wun wrote:
> > Thanks David,
> >
> >
> >
> > After copied the jstl and standard dot jar files into the directory:
> >
> > linux:~/tomcat/apache-tomcat-5.5.26/webapps/DBTest/WEB-INF/lib # ls
> > .  ..  jstl.jar  mysql-connector-java-5.1.3-rc-bin.jar  standard.jar
> >
> >
> >
> > I got the following different errors:
> >
> > (In line 4, what is jdbc/TestDB? I have database called javatest, and 
> table 
> > testdata. Should I rename it to jdbc/javatest?
> >
> >
> >
> >
> >
> > HTTP Status 500 - 
> >
> > type Exception report
> >
> > message 
> >
> > description The server encountered an internal error () that prevented 
> it 
> > from fulfilling this request.
> >
> > exception org.apache.jasper.JasperException: Exception in JSP: 
> > /testdb.jsp:4
> >
> > 1: <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql" %>
> > 2: <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
> > 3: 
> > 4: <sql:query var="rs" dataSource="jdbc/TestDB">
> > 5: select id, foo, bar from testdata
> > 6: </sql:query>
> > 7: 
> >
> >
> > Stacktrace:
> > 	
> > 
> org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:451)
> > 	
> > 
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:355)
> > 	
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
> > 	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
> > 	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> >
> > root cause javax.servlet.ServletException: Unable to get connection, 
> > DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: 
> Cannot 
> > create JDBC driver of class '' for connect URL 'null'"
> > 	
> > 
> org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:841)
> > 	
> > 
> org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:774)
> > 	org.apache.jsp.testdb_jsp._jspService(testdb_jsp.java:82)
> > 	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
> > 	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> > 	
> > 
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
> > 	
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
> > 	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
> > 	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> >
> > root cause javax.servlet.jsp.JspException: Unable to get connection, 
> > DataSource invalid: "org.apache.tomcat.dbcp.dbcp.SQLNestedException: 
> Cannot 
> > create JDBC driver of class '' for connect URL 'null'"
> > 	
> > 
> org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:276)
> > 	
> > 
> org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:159)
> > 	
> > 
> org.apache.jsp.testdb_jsp._jspx_meth_sql_005fquery_005f0(testdb_jsp.java:101)
> > 	org.apache.jsp.testdb_jsp._jspService(testdb_jsp.java:58)
> > 	org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:98)
> > 	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> > 	
> > 
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:331)
> > 	
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
> > 	org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)      
>   
> > javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> >
> >
> >
> >
> >
> >   
> >> ----- Original Message -----
> >> From: David Smith
> >> Sent: 03/09/08 01:23 am
> >> To: Tomcat Users List
> >> Subject: Re: Can't execute servlet project
> >>
> >> Download the binary zip file and expand it.  Within it is a lib 
> >> directory with just standard.jar and jstl.jar.
> >>
> >> --David
> >>
> >> sam wun wrote:
> >>     
> >>> I just went to the website , very confused.
> >>>
> >>> The taglib file is not a jar file. they are binary or source file.
> >>>
> >>> And I couldn't find standard.jar file either.
> >>>
> >>>
> >>>
> >>> Thanks
> >>>
> >>>
> >>>
> >>>   
> >>>       
> >>>> ----- Original Message -----
> >>>> From: David Smith
> >>>> Sent: 02/09/08 11:44 pm
> >>>> To: Tomcat Users List
> >>>> Subject: Re: Can't execute servlet project
> >>>>
> >>>> Hmmm... good question.  I moved over to Maven and don't manually 
> >>>> download these any more.  This looks like it should do the trick:
> >>>>
> >>>> Try 
> >>>>
> >>>>         
> >> 
> http://jakarta.apache.org/site/downloads/downloads_taglibs-standard.cgi
> >>     
> >>>> --David
> >>>>
> >>>> sam wun wrote:
> >>>>     
> >>>>         
> >>>>> Hi David,
> >>>>>
> >>>>>
> >>>>>
> >>>>> No, I don't have this 2 jar files in the common/lib/ directory.
> >>>>>
> >>>>> where can I download it from?
> >>>>>
> >>>>>
> >>>>>
> >>>>> Thanks
> >>>>>
> >>>>> Sam
> >>>>>
> >>>>>
> >>>>>
> >>>>>
> >>>>>   
> >>>>>       
> >>>>>           
> >>>>>> ----- Original Message -----
> >>>>>> From: David Smith
> >>>>>> Sent: 02/09/08 10:39 pm
> >>>>>> To: Tomcat Users List
> >>>>>> Subject: Re: Can't execute servlet project
> >>>>>>
> >>>>>> Do you have jstl.jar and standard.jar in your WEB-INF/lib 
> directory?
> >>>>>>
> >>>>>> --David
> >>>>>>
> >>>>>> sam wun wrote:
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>> Hi,
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> I have added testdb.jsp in the following path in Suse linux
(the 
> >>>>>>>           
> >>>>>>>               
> >>>> tomcat 
> >>>>     
> >>>>         
> >>>>>>> server):
> >>>>>>>
> >>>>>>> /tomcat/apache-tomcat-5.5.26/webapps/DBTest/
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> The content of the testdb.jsp code is:
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"
%>
> >>>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"
%>
> >>>>>>>
> >>>>>>> <sql:query var="rs" dataSource="jdbc/TestDB">
> >>>>>>> select FIRST_NAME from DBTest.Customer
> >>>>>>> </sql:query>
> >>>>>>>
> >>>>>>> <html>
> >>>>>>>   <head>
> >>>>>>>     <title>DB Test</title>
> >>>>>>>   </head>
> >>>>>>>   <body>
> >>>>>>>
> >>>>>>>   <h2>Results</h2>
> >>>>>>>
> >>>>>>> <c:forEach var="row" items="${rs.rows}">
> >>>>>>>     Foo ${row.foo}<br/>
> >>>>>>>     Bar ${row.bar}<br/>
> >>>>>>> </c:forEach>
> >>>>>>>
> >>>>>>>   </body>
> >>>>>>> </html>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> when I execute url 10.1.9.1:8080/testdb.jsp in firefox web

> browser, 
> >>>>>>>           
> >>>>>>>               
> >>>> it 
> >>>>     
> >>>>         
> >>>>>>> shown the following error:
> >>>>>>>
> >>>>>>> HTTP Status 500 - 
> >>>>>>>
> >>>>>>> type Exception report
> >>>>>>>
> >>>>>>> message 
> >>>>>>>
> >>>>>>> description The server encountered an internal error ()
that 
> >>>>>>>           
> >>>>>>>               
> >>>> prevented 
> >>>>     
> >>>>         
> >>>>>>>       
> >>>>>>>           
> >>>>>>>               
> >>>>>> it 
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>> from fulfilling this request.
> >>>>>>>
> >>>>>>> exception org.apache.jasper.JasperException: The absolute
uri: 
> >>>>>>> http://java.sun.com/jsp/jstl/sql cannot be resolved in either

> >>>>>>>               
> >> web.xml 
> >>     
> >>>>>>>       
> >>>>>>>           
> >>>>>>>               
> >>>>>> or 
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>> the jar files deployed with this application
> >>>>>>> 	
> >>>>>>>
> >>>>>>>       
> >>>>>>>           
> >>>>>>>               
> >> 
> org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:51)
> >>     
> >>>>     
> >>>>         
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>> 	
> >>>>>>>
> >>>>>>>       
> >>>>>>>           
> >>>>>>>               
> >> 
> org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:409)
> >>     
> >>>>     
> >>>>         
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>> 	
> >>>>>>>
> >>>>>>>       
> >>>>>>>           
> >>>>>>>               
> >> 
> org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:116)
> >>     
> >>>>     
> >>>>         
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>> 	
> >>>>>>>
> >>>>>>>       
> >>>>>>>           
> >>>>>>>               
> >> 
> org.apache.jasper.compiler.TagLibraryInfoImpl.generateTLDLocation(TagLibraryInfoImpl.java:317)
> >>     
> >>>>     
> >>>>         
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>> 	
> >>>>>>>
> >>>>>>>       
> >>>>>>>           
> >>>>>>>               
> >> 
> org.apache.jasper.compiler.TagLibraryInfoImpl.<init>(TagLibraryInfoImpl.java:148)
> >>     
> >>>>     
> >>>>         
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>> 	
> >>>>>>>       
> >>>>>>>           
> >>>>>>>               
> >> 
> org.apache.jasper.compiler.Parser.parseTaglibDirective(Parser.java:424)
> >>     
> >>>>     
> >>>>         
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>> 	
> org.apache.jasper.compiler.Parser.parseDirective(Parser.java:493)
> >>>>>>> 	
> org.apache.jasper.compiler.Parser.parseElements(Parser.java:1557)
> >>>>>>> 	org.apache.jasper.compiler.Parser.parse(Parser.java:127)
> >>>>>>> 	
> >>>>>>>
> >>>>>>>       
> >>>>>>>           
> >>>>>>>               
> >> 
> org.apache.jasper.compiler.ParserController.doParse(ParserController.java:212)
> >>     
> >>>>     
> >>>>         
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>> 	
> >>>>>>>
> >>>>>>>       
> >>>>>>>           
> >>>>>>>               
> >> 
> org.apache.jasper.compiler.ParserController.parse(ParserController.java:101)
> >>     
> >>>>     
> >>>>         
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>> 	
> >>>>>>>               
> >> org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:156)
> >>     
> >>>>>>> 	org.apache.jasper.compiler.Compiler.compile(Compiler.java:296)
> >>>>>>> 	org.apache.jasper.compiler.Compiler.compile(Compiler.java:277)
> >>>>>>> 	org.apache.jasper.compiler.Compiler.compile(Compiler.java:265)
> >>>>>>> 	
> >>>>>>>
> >>>>>>>       
> >>>>>>>           
> >>>>>>>               
> >> 
> org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564)
> >>     
> >>>>     
> >>>>         
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>> 	
> >>>>>>>
> >>>>>>>       
> >>>>>>>           
> >>>>>>>               
> >> 
> org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302)
> >>     
> >>>>     
> >>>>         
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>> 	
> >>>>>>>       
> >>>>>>>           
> >>>>>>>               
> >> 
> org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329)
> >>     
> >>>>     
> >>>>         
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>> 	
> org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265)
> >>>>>>>
> >>>>>>> Here is the web.xml file I got:
> >>>>>>>
> >>>>>>> (in the path 
> /tomcat/apache-tomcat-5.5.26/webapps/DBTest/WEB-INF/)
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> <?xml version="1.0" encoding="UTF-8"?>
> >>>>>>> <web-app id="WebApp_ID" version="2.4" 
> >>>>>>> xmlns="http://java.sun.com/xml/ns/j2ee" 
> >>>>>>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
> >>>>>>> xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
> >>>>>>> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
> >>>>>>>         <display-name>
> >>>>>>>         DBTest</display-name>
> >>>>>>>         <servlet>
> >>>>>>>                 <description>
> >>>>>>>                 Create customer servlet</description>
> >>>>>>>                 <display-name>
> >>>>>>>                 CreateCustomerServlet</display-name>
> >>>>>>>                 
> >>>>>>> <servlet-name>CreateCustomerServlet</servlet-name>
> >>>>>>>                 <servlet-class>
> >>>>>>>                 
> >>>>>>> servlet.CreateCustomerServlet</servlet-class>
> >>>>>>>         </servlet>
> >>>>>>>         <servlet-mapping>
> >>>>>>>                 
> >>>>>>> <servlet-name>CreateCustomerServlet</servlet-name>
> >>>>>>>                 
> >>>>>>> <url-pattern>/CreateCustomerServlet</url-pattern>
> >>>>>>>         </servlet-mapping>
> >>>>>>>         <welcome-file-list>
> >>>>>>>                 <welcome-file>index.html</welcome-file>
> >>>>>>>                 <welcome-file>index.htm</welcome-file>
> >>>>>>>                 <welcome-file>index.jsp</welcome-file>
> >>>>>>>                 <welcome-file>default.html</welcome-file>
> >>>>>>>                 <welcome-file>default.htm</welcome-file>
> >>>>>>>                 <welcome-file>default.jsp</welcome-file>
> >>>>>>>         </welcome-file-list>
> >>>>>>>         <resource-ref>
> >>>>>>>                                 
> >>>>>>> <description>DB Connection</description>
> >>>>>>>                         
> >>>>>>> <res-ref-name>jdbc/TestDB</res-ref-name>
> >>>>>>>                                 
> >>>>>>> <res-type>javax.sql.DataSource</res-type>
> >>>>>>>                                 
> >>>>>>> <res-auth>Container</res-auth>
> >>>>>>>   </resource-ref>
> >>>>>>> </web-app>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>>
> >>>>>>> Thanks
> >>>>>>>
> >>>>>>> Sam
> >>>>>>>
> >>>>>>> 	javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
> >>>>>>>
> >>>>>>>   
> >>>>>>>       
> >>>>>>>           
> >>>>>>>               
> >>>>>>>> ----- Original Message -----
> >>>>>>>> From: Martin Gainty
> >>>>>>>> Sent: 28/08/08 10:07 pm
> >>>>>>>> To: sw2018@gmx.com
> >>>>>>>> Subject: RE: Can't execute servlet project
> >>>>>>>>
> >>>>>>>> david's advice is correct..
> >>>>>>>>
> >>>>>>>> configure ./META-INF/ApplicationContext.xml 
> >>>>>>>> <Context path="/DBTest" docBase="DBTest"
> >>>>>>>>         debug="5" reloadable="true" crossContext="true">
> >>>>>>>>
> >>>>>>>>     <!-- maxActive: 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.
> >>>>>>>>          -->
> >>>>>>>>
> >>>>>>>>     <!-- maxIdle: Maximum number of idle dB connections
to 
> retain 
> >>>>>>>>                 
> >> in 
> >>     
> >>>>>>>> pool.
> >>>>>>>>          Set to -1 for no limit.  See also the DBCP

> documentation 
> >>>>>>>>                 
> >> on 
> >>     
> >>>>>>>>         
> >>>>>>>>             
> >>>>>>>>                 
> >>>>>> this
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>>>          and the minEvictableIdleTimeMillis configuration

> >>>>>>>>                 
> >> parameter.
> >>     
> >>>>>>>>          -->
> >>>>>>>>
> >>>>>>>>     <!-- maxWait: 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.
> >>     
> >>>>>>>>          -->
> >>>>>>>>
> >>>>>>>>     <!-- username and password: MySQL dB username
and password 
> for 
> >>>>>>>>             
> >>>>>>>>                 
> >>>> dB 
> >>>>     
> >>>>         
> >>>>>>>> connections  -->
> >>>>>>>>
> >>>>>>>>     <!-- driverClassName: Class name for the old
mm.mysql JDBC 
> >>>>>>>>             
> >>>>>>>>                 
> >>>> driver 
> >>>>     
> >>>>         
> >>>>>>>>         
> >>>>>>>>             
> >>>>>>>>                 
> >>>>>> is
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>>>          org.gjt.mm.mysql.Driver - we recommend using

> Connector/J 
> >>>>>>>>         
> >>>>>>>>             
> >>>>>>>>                 
> >>>>>> though.
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>>>          Class name for the official MySQL Connector/J
driver is 
> >>>>>>>> com.mysql.jdbc.Driver.
> >>>>>>>>          -->
> >>>>>>>>
> >>>>>>>>     <!-- url: 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.
> >>>>>>>>          -->
> >>>>>>>>
> >>>>>>>>   <Resource name="jdbc/TestDB" auth="Container" 
> >>>>>>>> type="javax.sql.DataSource"
> >>>>>>>>                maxActive="100" maxIdle="30" maxWait="10000"
> >>>>>>>>                username="javauser" password="javadude"

> >>>>>>>> driverClassName="com.mysql.jdbc.Driver"
> >>>>>>>>                
> >>>>>>>> url="jdbc:mysql://localhost:3306/javatest?autoReconnect=true"/>
> >>>>>>>>
> >>>>>>>> </Context>
> >>>>>>>> //sub in the username and password for the DB
> >>>>>>>> also in /WEB-INF/web.xml you would need this entry
> >>>>>>>> <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
> >>>>>>>>     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >>>>>>>>     xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
> >>>>>>>> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
> >>>>>>>>     version="2.4">
> >>>>>>>>   <description>MySQL Test App</description>
> >>>>>>>>   <resource-ref>
> >>>>>>>>       <description>DB Connection</description>
> >>>>>>>>       <res-ref-name>jdbc/TestDB</res-ref-name>
> >>>>>>>>       <res-type>javax.sql.DataSource</res-type>
> >>>>>>>>       <res-auth>Container</res-auth>
> >>>>>>>>   </resource-ref>
> >>>>>>>> </web-app>
> >>>>>>>> then put in this test code changing :
> >>>>>>>> DBNAME to the name of your Database
> >>>>>>>> TABLE to the name of the table in DBNAME you want to
query
> >>>>>>>> COLUMN for the specific attribute to query
> >>>>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/sql"
prefix="sql" 
> %>
> >>>>>>>> <%@ taglib uri="http://java.sun.com/jsp/jstl/core"
prefix="c" %>
> >>>>>>>>
> >>>>>>>> <sql:query var="rs" dataSource="jdbc/TestDB">
> >>>>>>>> select COLUMN from DBNAME.TABLE
> >>>>>>>> </sql:query>
> >>>>>>>>
> >>>>>>>> <html>
> >>>>>>>>   <head>
> >>>>>>>>     <title>DB Test</title>
> >>>>>>>>   </head>
> >>>>>>>>   <body>
> >>>>>>>>
> >>>>>>>>   <h2>Results</h2>
> >>>>>>>>
> >>>>>>>> <c:forEach var="row" items="${rs.rows}">
> >>>>>>>>     Foo ${row.foo}<br/>
> >>>>>>>>     Bar ${row.bar}<br/>
> >>>>>>>> </c:forEach>
> >>>>>>>>
> >>>>>>>>   </body>
> >>>>>>>> </html>
> >>>>>>>>
> >>>>>>>> if you need UNICODE support or Character Large Object
(strings > 
> >>>>>>>>                 
> >> 64k 
> >>     
> >>>>>>>>         
> >>>>>>>>             
> >>>>>>>>                 
> >>>>>> in 
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>>> length) download JDBC 4 driver
> >>>>>>>> http://dev.mysql.com/downloads/connector/j/5.1.html
> >>>>>>>>
> >>>>>>>> personally I am using the 'older' version of MYSQL so
I use the 
> >>>>>>>>                 
> >> 3.1 
> >>     
> >>>>>>>>         
> >>>>>>>>             
> >>>>>>>>                 
> >>>>>> jar 
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>>> which you can acquire here
> >>>>>>>> http://dev.mysql.com/downloads/connector/j
> >>>>>>>>
> >>>>>>>> location of driver classes:
> >>>>>>>>
> >>>>>>>> is located in $TOMCAT_HOME/common/lib
> >>>>>>>> personally I dont like putting anything in common since
it will 
> >>>>>>>>             
> >>>>>>>>                 
> >>>> affect 
> >>>>     
> >>>>         
> >>>>>>>> all webapps but i usually 
> >>>>>>>> place in /WEB-INF/lib
> >>>>>>>>
> >>>>>>>> and please follow david's advice and read the tutorial
> >>>>>>>>
> >>>>>>>> Martin 
> >>>>>>>> ______________________________________________ 
> >>>>>>>> Disclaimer and confidentiality note 
> >>>>>>>> Everything in this e-mail and any attachments relates
to the 
> >>>>>>>>             
> >>>>>>>>                 
> >>>> official 
> >>>>     
> >>>>         
> >>>>>>>> business of Sender. This transmission is of a confidential

> nature 
> >>>>>>>>             
> >>>>>>>>                 
> >>>> and 
> >>>>     
> >>>>         
> >>>>>>>> Sender does not endorse distribution to any party other
than 
> >>>>>>>>             
> >>>>>>>>                 
> >>>> intended 
> >>>>     
> >>>>         
> >>>>>>>> recipient. Sender does not necessarily endorse content
contained 
> >>>>>>>>         
> >>>>>>>>             
> >>>>>>>>                 
> >>>>>> within 
> >>>>>>     
> >>>>>>         
> >>>>>>             
> >>>>>>>> this transmission. 
> >>>>>>>>
> >>>>>>>>
> >>>>>>>>     
> >>>>>>>>         
> >>>>>>>>             
> >>>>>>>>                 
> >>>>>>>>> Date: Thu, 28 Aug 2008 11:02:52 +0200
> >>>>>>>>> From: sw2018@gmx.com
> >>>>>>>>> Subject: Re: Re: Can't execute servlet project
> >>>>>>>>> To: users@tomcat.apache.org; users@tomcat.apache.org
> >>>>>>>>>
> >>>>>>>>> Hi,
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> I couldn't find an installation document about installing
the 
> >>>>>>>>>               
> >>>>>>>>>                   
> >>>> driver.
> >>>>     
> >>>>         
> >>>>>>>>> I;ve downloaded the driver:
> >>>>>>>>>
> >>>>>>>>> linux:~/tomcat/apache-tomcat-5.5.26/common/lib #
ls 
> >>>>>>>>> mysql-connector-java-5.1.3-rc-bin.jar
> >>>>>>>>> mysql-connector-java-5.1.3-rc-bin.jar
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> Do you know how to configure tomcat to make use
of it?
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>> Thanks
> >>>>>>>>>
> >>>>>>>>> Sam
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>
> >>>>>>>>>       
> >>>>>>>>>           
> >>>>>>>>>               
> >>>>>>>>>                   
> 
> 
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message