tomcat实现连接数据库

192.168.30.23
mkdir  /web/webapp
tar xf SLSaleSystem.tar.gz -C /web/webapp
ls /web/wenbapp
vim /usr/local/tomcat8/conf/server.xml
<Context docBase="/web/webapp/SLSaleSystem" path="" reloadable="flase" >
        </Context>
/usr/local/tomcat8/bin/shutdown.sh
/usr/local/tomcat8/bin/startup.sh
访问http://192.168.30.23:8080
显示会员商城的后台
连接数据库mariadb
在192.168.30.24上
yum -y intstall mariadb mariadb-server
systemctl start mariadb
mysql

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.01 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> exit
Bye
[root@tomcat~]# rz -E
rz waiting to receive.
[root@tomcat ~]# mysql -uroot < slsaledb-2014-4-10.sql

在192.168.30.23
[root@tomcat ~]# vim /web/webapp/SLSaleSystem/WEB-INF/classes/jdbc.properties
driverClassName=com.mysql.jdbc.Driver
url=jdbc\:mysql\://192.168.30.24\:3306/slsaledb?useUnicode\=true&characterEncoding\=UTF-8
uname=admin
password=123456
minIdle=10
maxIdle=50
initialSize=5
maxActive=100
maxWait=100
removeAbandonedTimeout=180
removeAbandoned=true

[root@tomcat ~]# /usr/local/tomcat7/bin/shutdown.sh


[root@tomcat ~]# /usr/local/tomcat7/bin/startup.sh

访问192.168.30.23:8080




















posted @ 2019-05-25 08:32  #赵程#  阅读(706)  评论(0编辑  收藏  举报