Here are the configuration properties for Tomcat's standard data source resource factory (org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory): driverClassName — Fully qualified Java class name of the JDBC driver to be used. MaxTotal — The maximum number of active instances that can be allocated from this pool at the same time. What's up guys, Tomcat here! Here you'll find Forza, Need For Speed, Spin Tires, GTA, and lots of other racing and driving games to watch! And I guarantee you'll be entertained by what you find.
MySQL provides standards-based drivers for JDBC, ODBC, and .Net enabling developers to build database applications in their language of choice. In addition, a native C library allows developers to embed MySQL directly into their applications.
Developed by MySQL | |
---|---|
ADO.NET Driver for MySQL (Connector/NET) | Download |
ODBC Driver for MySQL (Connector/ODBC) | Download |
JDBC Driver for MySQL (Connector/J) | Download |
Node.js Driver for MySQL (Connector/Node.js) | Download |
Python Driver for MySQL (Connector/Python) | Download |
C++ Driver for MySQL (Connector/C++) | Download |
C Driver for MySQL (Connector/C) | Download |
C API for MySQL (mysqlclient) | Download |
These drivers are developed and maintained by the MySQL Community.
Developed by Community | |
---|---|
PHP Drivers for MySQL (mysqli, ext/mysqli, PDO_MYSQL, PHP_MYSQLND) | Download |
Perl Driver for MySQL (DBD::mysql) | Download |
Ruby Driver for MySQL (ruby-mysql) | Download |
C++ Wrapper for MySQL C API (MySQL++) | Download |
Driver Tomatoes
Business web applications rely on databases. Therefore, you will probably be required to make a connection to your relational database during the development of a web application. Java accesses relational databases through JDBC (Java Database Connectivity). As of JDBC 2, the database is represented to Tomcat as a data source.In this topic I will discuss establishing a JDBC connection to a MySQL data source in Tomcat.
To learn how to establish a JDBC connection in Apache Tomcat, follow these four steps:
Drivers Tomcat Training
- I will present the steps using the MySQL database and sample web application we use in our Webucator Tomcat training. The database name is
test
and is used by the 'Cool Garden Tools' web application. It contains one table, theGardenTools
table. The JNDI (Java Naming and Directory Interface) name referenced in the web application isjdbc/gardentools
. - A resource entry is required in the Tomcat configuration. In my example, I have placed my resource element in
CATALINA_BASE/conf/context.xml
, e.g.,c:/Tomcat8/conf/context.xml
: Thename
attribute value must match the name of the JNDI resource coded in thelookup
method of aContext
in the application code. ThemaxTotal
,maxIdle
andmaxWaitMillis
are parameters for Database Connection Pool (DBCP) and specify the total connections allowed for this resource, the maximum number of idle, or unused, connections and the maximum wait time in milliseconds before throwing an exception if all connections are in use (a value of -1 indicates that the wait time is infinite), respectively. Note that theurl
anddriverClassName
are specific to database vendor. For examples of Oracle and PostgreSQL visit the Tomcat documentation for JNDI - Once you save
context.xml
, Tomcat will detect the updated file, and the resource will be available to your web application. - As an example, here is the Cool Garden Tools welcome page displaying the tools from the
GardenTools
table:
The table displays the tool ID and description for each tool in the database.