In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "how to use tomcat+mysql technology in java environment", the explanation content in the article is simple and clear, easy to learn and understand, please follow the idea of Xiaobian slowly, study and learn "how to use tomcat+mysql technology in java environment" together!
Tomcat + MySQL
========================================================
Solution 1: Tomcat1
Scenario 2: Apache (Load Balancer) Tomcat2
Tomcat3
Tomcat1
Solution 3: Nginx (Load Balancer) Tomcat2
Tomcat3
========================================================
Tomcat HTTP Server
1. Java environment
[root@Tomcat ~]# java -version
java version "1.7.0_09-icedtea"
OpenJDK Runtime Environment (rhel-2.3.4.1.el6_3-x86_64)
OpenJDK 64-Bit Server VM (build 23.2-b09, mixed mode)
[root@Tomcat ~]# vim /etc/profile
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre/
PATH=$PATH:$JAVA_HOME/bin
export JAVA_HOME PATH
[root@Tomcat ~]# source /etc/profile
[root@Tomcat ~]# env |grep JAVA
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre/
2. Tomcat
Install Tomcat
[root@master jsp]# tar xf apache-tomcat-7.0.34.tar.gz -C /usr/local/
[root@master jsp]# cd /usr/local/
[root@master local]# ln -s apache-tomcat-7.0.34/ tomcat
Define environment variables required for Tomcat
[root@master local]# vim /etc/profile //define Tomcat environment variables
CATALINA_HOME=/usr/local/tomcat //Tomcat installation directory
export CATALINA_HOME
[root@master local]# source /etc/profile
[root@master local]# env |grep HOME
CATALINA_HOME=/usr/local/tomcat
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre/
HOME=/root
start Tomcat
Method 1:
[root# /usr/local/tomcat/bin/www.example.com//start startup.sh
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/java/jdk1.7.0_11
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@master ~]# netstat -tnlp |grep java
tcp 0 0 ::ffff:127.0.0.1:8005 :::* LISTEN 6191/java
tcp 0 0 :::8009 :::* LISTEN 6191/java
tcp 0 0 :::8080 :::* LISTEN 6191/java
[root# /usr/local/tomcat/bin/www.example.com//stop shutdown.sh
========================================================
Method 2: System V Scripting
#[root@master ~]# vim /etc/init.d/tomcat
#!/ bin/bash
# Init file for Tomcat server daemon
#
# chkconfig: 2345 96 14
# description: Tomcat server daemon
JAVA_OPTS='-Xms64m -Xmx128m'
JAVA_HOME=/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre/
CATALINA_HOME=/usr/local/tomcat
export JAVA_OPTS JAVA_HOME CATALINA_HOME
exec $CATALINA_HOME/bin/catalina.sh $*
[root@master ~]# chmod a+x /etc/init.d/tomcat
[root@master ~]# chkconfig --add tomcat
[root@master ~]# chkconfig tomcat --list
tomcat 0: Off 1: Off 2: Enabled 3: Enabled 4: Enabled 5: Enabled 6: Off
[root@master ~]# chkconfig tomcat on
[root@master ~]#
[root@master ~]# service tomcat stop
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre/
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
[root@master ~]# service tomcat start
Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre/
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar
========================================================
3. test
http://192.168.2.251:8080/
Tomcat Connection to MySQL
1. Install MySQL (see previous article, How to compile mysql)
2. Provides class files for Tomcat to connect to Mysql
[root@master jsp]# tar xf mysql-connector-java-5.0.8.tar.gz
[root@master jsp]# cd mysql-connector-java-5.0.8
[root@master mysql-connector-java-5.0.8]# cp mysql-connector-java-5.0.8-bin.jar /usr/local/tomcat/lib/
[root@master jsp]# service tomcat stop
[root@master jsp]# service tomcat start
Deployment JavaCenter_Home
1. Tomcat default website directory
[root@master jsp]# ls /usr/local/tomcat/webapps/ //base directory of default website
docs examples host-manager manager ROOT
[root@master jsp]# ls /usr/local/tomcat/webapps/ROOT //Home directory of default web site
asf-logo.png bg-nav-item.png favicon.ico tomcat.gif WEB-INF
asf-logo-wide.gif bg-nav.png index.jsp tomcat.png
bg-button.png bg-upper.png RELEASE-NOTES.txt tomcat-power.gif
bg-middle.png build.xml tomcat.css tomcat.svg
[root@master ~]# cd /usr/local/tomcat/webapps/ROOT/
[root@master ROOT]# rm -rf * //Delete default site content
2. Deploying JavaCenter_Home
[root@master jsp]# unzip JavaCenter_Home_2.0_Source_UTF8
[root@master jsp]# cd JavaCenter_Home_2.0_Source_UTF8
[root@master JavaCenter_Home_2.0_Source_UTF8]# ls
source
[root@master JavaCenter_Home_2.0_Source_UTF8]# cd source/
[root@master source]# ls
src WebRoot
[root@master source]# cd WebRoot/
[root@master WebRoot]#
[root@master WebRoot]# ls
admin attachment cp.jsp editor.jsp image js.jsp network.jsp template xmlrpc.jsp
admincp.jsp avatar.jsp crossdomain.xml errors index.jsp link.jsp rss.jsp theme
api config.properties data favicon.ico install magic.jsp source userapp.jsp
app.jsp contact.jsp do.jsp help.jsp invite.jsp META-INF space.jsp WEB-INF
[root@master WebRoot]# cp -rf * /usr/local/tomcat/webapps/ROOT/
[root@master source]# service tomcat stop
[root@master source]# service tomcat start
Thank you for reading, the above is "java environment how to use tomcat+mysql technology" content, after the study of this article, I believe we have a deeper understanding of how to use tomcat+mysql technology in java environment, the specific use of the situation also needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.