Tomcat Driver



Each JDBC driver has its own specificities, read the JDBC driver documentation to learn more. The important parts are: name - the JNDI resource name that you will use in the Elements Connect datasource configuration - it must be unique driverClassName - unique for every JDBC driver; url - the JDBC connection URL, usual well documentation; To learn more, read the official Tomcat documentation. Connecting Tomcat to a MySQL database Now that we have a basic understanding of how Tomcat uses JDBC, DBCP, and JNDI to connect to databases, it's time to look at the specific steps required to get Tomcat talking to MySQL. Step 1: Download the MySQL JDBC driver The driver that JDBC needs to connect to MySQL is called Connector/J. To run your application, the Tomcat application server must find an SQL Server JDBC driver file in the Apache Tomcat installation lib subdirectory. To ensure that Tomcat finds the file there, copy the installed sqljdbc4.jar file to the lib subdirectory of your Apache Tomcat installation. Tomcat DataSource JNDI Configuration Example – server.xml. Add below code in the tomcat server.xml file. The code should be added in the GlobalNamingResources element. Also make sure that database driver is present in the tomcat lib directory, so in this case mysql jdbc jar have to be present in the tomcat lib.

The following instructions are based on the instructions for Tomcat-5.x, available at http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html which is current at the time this document was written.

First, install the .jar file that comes with Connector/J in $CATALINA_HOME/common/lib so that it is available to all applications installed in the container.

Next, configure the JNDI DataSource by adding a declaration resource to $CATALINA_HOME/conf/server.xml in the context that defines your web application:

Note that Connector/J 5.1.3 introduced a facility whereby, rather than use a validationQuery value of SELECT 1, it is possible to use validationQuery with a value set to /* ping */. This sends a ping to the server which then returns a fake result set. This is a lighter weight solution. It also has the advantage that if using ReplicationConnection or LoadBalancedConnection type connections, the ping will be sent across all active connections. The following XML snippet illustrates how to select this option:

Note that /* ping */ has to be specified exactly.

In general, follow the installation instructions that come with your version of Tomcat, as the way you configure datasources in Tomcat changes from time to time, and if you use the wrong syntax in your XML file, you will most likely end up with an exception similar to the following:

Note that the auto-loading of drivers having the META-INF/service/java.sql.Driver class in JDBC 4.0 and above causes an improper undeployment of the Connector/J driver in Tomcat on Windows. Namely, the Connector/J jar remains locked. This is an initialization problem that is not related to the driver. The possible workarounds, if viable, are as follows: use 'antiResourceLocking=true' as a Tomcat Context attribute, or remove the META-INF/ directory.

Content

Apache Tomcat

The Apache Tomcat® software is an open source implementationof the Java Servlet, JavaServer Pages, Java Expression Language and JavaWebSocket technologies. The Java Servlet, JavaServer Pages, Java ExpressionLanguage and Java WebSocket specifications are developed under theJava CommunityProcess.

The Apache Tomcat software is developed in an open and participatoryenvironment and released under theApache License version 2. TheApache Tomcat project is intended to be a collaboration of the best-of-breeddevelopers from around the world. We invite you to participate in this opendevelopment project. To learn more about getting involved,click here.

Apache Tomcat software powers numerous large-scale, mission-critical webapplications across a diverse range of industries and organizations. Some ofthese users and their stories are listed on thePoweredBywiki page.

Apache Tomcat, Tomcat, Apache, the Apache feather, and the Apache Tomcatproject logo are trademarks of the Apache Software Foundation.

2021-02-05 Tomcat 7.0.108 Released

The Apache Tomcat Project is proud to announce the release of version 7.0.108 ofApache Tomcat. This release contains a number of bug fixes and improvementscompared to version 7.0.107.

  • Fix a potential file descriptor leak when WebSocket connections are attempted and fail. Patch provided by Maurizio Adami.

Full details of these changes, and all the other changes, are available in theTomcat 7 changelog.

Note: End of life date for Apache Tomcat 7.0.x is announced.Read more...

2021-02-02 Tomcat 10.0.2 Released

The Apache Tomcat Project is proud to announce the release of version 10.0.2of Apache Tomcat. This release is the first stable release in the 10.0.x seriesand is targeted at Jakarta EE 9.

Users of Tomcat 10 onwards should be aware that, as a result of the move fromJava EE to Jakarta EE as part of the transfer of Java EE to the EclipseFoundation, the primary package for all implemented APIs has changed fromjavax.* to jakarta.*. This will almost certainlyrequire code changes to enable applications to migrate from Tomcat 9 and earlierto Tomcat 10 and later. Amigrationtool is under development to aid this process.

The notable changes in this release are:

  • Add support for using Unix domain sockets for NIO when running on Java 16 or later.
  • Add a new StringInterpreter interface that allows applications to provide customised string attribute value to type conversion within JSPs. This allows applications to provide a conversion implementation that is optimised for the application.
  • Add peerAddress to coyote request, which contains the IP address of the direct connection peer. If a reverse proxy sits in front of Tomcat and the RemoteIp(Valve|Filter) is used, the peerAddress is likely to differ from the remoteAddress. The remoteAddress is likely to contain the address of the client in front of the reverse proxy, not the address of the proxy itself.

Full details of these changes, and all the other changes, are available in theTomcat 10changelog.

2021-02-02 Tomcat 9.0.43 Released

The Apache Tomcat Project is proud to announce the release of version 9.0.43of Apache Tomcat. The notable changes compared to 9.0.41 include:

  • Add support for using Unix domain sockets for NIO when running on Java 16 or later.
  • Add a new StringInterpreter interface that allows applications to provide customised string attribute value to type conversion within JSPs. This allows applications to provide a conversion implementation that is optimised for the application.
  • Add peerAddress to coyote request, which contains the IP address of the direct connection peer. If a reverse proxy sits in front of Tomcat and the RemoteIp(Valve|Filter) is used, the peerAddress is likely to differ from the remoteAddress. The remoteAddress is likely to contain the address of the client in front of the reverse proxy, not the address of the proxy itself.

Full details of these changes, and all the other changes, are available in theTomcat 9changelog.

2020-02-03 Tomcat 8.5.63 Released

The Apache Tomcat Project is proud to announce the release of version 8.5.63of Apache Tomcat. Apache Tomcat 8.5.x replaces 8.0.x and includes new featurespulled forward from Tomcat 9.0.x. The minimum Java version and implementedspecification versions remain unchanged. The notable changes comparedto 8.5.61 include:

  • Add a new StringInterpreter interface that allows applications to provide customised string attribute value to type conversion within JSPs. This allows applications to provide a conversion implementation that is optimised for the application.
  • Add peerAddress to coyote request, which contains the IP address of the direct connection peer. If a reverse proxy sits in front of Tomcat and the RemoteIp(Valve|Filter) is used, the peerAddress is likely to differ from the remoteAddress. The remoteAddress is likely to contain the address of the client in front of the reverse proxy, not the address of the proxy itself.
  • Escape elements in the access log that need to be escaped for the access log to be parsed unambiguously.

Full details of these changes, and all the other changes, are available in theTomcat 8.5changelog.

2020-12-21 Tomcat Native 1.2.26 Released

The Apache Tomcat Project is proud to announce the release of version 1.2.26 ofTomcat Native. The notable changes since 1.2.25 include:

  • Windows binaries built using OpenSSL 1.1.1i
  • Expose support for Unix domain sockets (bug 64942)

Download |ChangeLog for 1.2.26

2020-03-06 Tomcat Connectors 1.2.48 Released

Tomcat Rider

The Apache Tomcat Project is proud to announce the release of version 1.2.48 ofApache Tomcat Connectors.This version fixes a number of bugs found in previous releases.

Download |ChangeLog for 1.2.48

Tomcat

2015-03-17 Apache Standard Taglib 1.2.5 Released

The Apache Tomcat Project is proud to announce the release of version 1.2.5 ofthe Standard Taglib. This tag library provides Apache's implementation of the JSTL 1.2 specification.

Version 1.2.5 is a minor bug fix release reverting a change made in 1.2.1 where<c:import> modified the HTTP method during POST operations, and fixing anissues that resulted in an AccessControlException during startup unlesspermission was granted to read the accessExternalEntity property.

Please see the Taglibs section for more details.

Download |Changes

2013-11-11 Tomcat Maven Plugin 2.2 Released

The Apache Tomcat team is pleased to announce the release of Tomcat Maven Plugin 2.2.Changelog available here.

Tomcat Driver

Tomcat Version

The Apache Tomcat Maven Plugin provides goalsto manipulate WAR projects within the Apache Tomcat servlet container.

The binaries are available from Maven repositories. You should specify theversion in your project's plugin configuration:

or

Tomcat Driverclassname Sql Server

Old news