Any Web Project, Web App or Website is useless without any link to Backend Database. Static and Dynamic websites make the difference. These days, dynamic websites are common. Dynamic websites fetch data from backend database and display the data to the user. Tomcat is a HTTP enabled web server that has capability to run Java Servlets and Java Server Pages. Backend databases are MySQL, Oracle, DB2, PostgreSQL and Sybase are a few. In this tutorial we shall Install MySQL and Configure Tomcat on Windows 10 operating system.
Install MySQL and Configure Tomcat on Windows 10
MySQL and Tomcat are a combination of a Database Server and a HTTP Server. MySQL is available on various versions and configurations. At the time of writing this article, MySQL 5.7 is most widely used Database server in Wordpress, Joomla and Drupal websites. Though MySQL 8 is available, it is not offered by Cloud Servers and Shared Hosting Providers.
If you go to MySql.com, you will be confused to see many links and versions. Students find it frustrating to search for the version they want. So directly follow the below links for download.
Download here on MySQL 5.7 and MySQL 5.6
Download here on MySQL 8.0
Installing MySQL Database Connectors
You need to install some drivers to bridge a Web Server and the actual MySQL server. Some of the available Database Connectors are ODBC, JDBC, Node.js, Python, C++, C, C API and ADO.NET. Download one these servers from the below link.
Installing Tomcat on Windows
You can easily install Tomcat on Windows 10, 8 and 7 operating systems using an Installable EXE file. After installation, you need to configure some global system variables using the Tomcat Tutorial. Make sure this similar entry is there under PATH variable, C:\Program Files\Java\jdk1.8.0_131\bin.
Now, you need a JDBC Connector to establish a connection between Tomcat and MySQL. If you do not see Window Operating System under OS, choose Platform Independent Option.
Configuring Tomcat With MySQL JDBC Driver on Windows
It is not just enough to install MySQL and Tomcat and think everything works fine. You still need to bridge the gap between Backend Database and Server. Simply copy the JDBC driver you downloaded on to Tomcat LIB Directory. Do not forget to Stop and Start Tomcat server after copying. JDBC driver is required only at Run Time to establish database connection and fetch data. If it fails, you will get Communication Link Failure exception like "com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure"
Compiling Java Servlets under Tomcat Server
Java Servlets are Java Source files with the file extension .JAVA. As usual, you need to compile java servlets like any other stand alone java programs. Class definitions for Java Servlets are available under Tomcat LIB directory as servlet-api.jar. Just copy the servlet-api.jar file under C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext. After copying, open a fresh command prompt to compile Servlets using the same Java command, javac filename.java.
> javac myservlet.java
This is how we install MySQL and configure Tomcat on Windows 10, 8 and 7. Remember that only linking of Tomcat with MySQL brought the expected results.
You can also read our good stuff articles / exams.
|C Arrays, Multidimensional Arrays and Pointers - Online Test 1
|C Structures and Pointers - Online Test 1
|C Data Types and Storage Classes Online Test 1
|C Functions and Pointers - Online Test 1