Tomcat连接数据库
需要三台虚拟机111 112 113 其中112 113安装Tomcat
1、以下是112 113的配置:
[root@localhost ~]# rz
z waiting to receive.**B0100000023be50
[root@localhost ~]# tar xf SLSaleSystem.tar.gz -C /web/webapp/
[root@localhost ~]# vim /usr/local/tomcat8/conf/server.xml
<Context docBase="/web/webapp/SLSaleSystem" path="" reloadable="flase">
</Context>
[root@localhost ~]# /usr/local/tomcat8/bin/shutdown.sh
[root@localhost ~]# /usr/local/tomcat8/bin/startup.sh
[root@localhost ~]# tail -f /usr/local/tomcat8/logs/catalina.out
2、111当做数据库和调度器
安装数据库
[root@localhost ~]# yum -y install mariadb mariadb-server
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# mysql //登录
Welcome to the MariaDB monitor. Commands end with ; or g.
Your MariaDB connection id is 2
Server version: 5.5.41-MariaDB MariaDB Server
Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
MariaDB [(none)]> create database slsaledb;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all on slsaledb.* to admin@'%' identified by'123456';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
[root@localhost ~]# mysql -uroot < slsaledb-2014-4-10.sql //导入一个.sql的文件
3、接下来更改前两台虚拟机,让他们连接数据库
[root@localhost ~]# vim /web/webapp/SLSaleSystem/WEB-INF/classes/jdbc.properties
url=jdbc:mysql://192.168.200.114:3306/slsaledb?useUnicode=true&characterEncoding=UTF-8
uname=admin
password=123456
[root@localhost ~]# /usr/local/tomcat8/bin/shutdown.sh
[root@localhost ~]# /usr/local/tomcat8/bin/startup.sh
4、去网页上访问,输入用户名密码登录。