当前位置:网站首页>ssm access database data error
ssm access database data error
2022-08-02 12:19:00 【CSDN Q&A】
ssm框架tomcatThe server reported an error accessing the database data,Guess it's a database connection problem and can't confirm it,有遇到过这种问题的吗
The error message from the server is as follows
tomcat日志信息
controller层的类
package com.duing.controller;import com.duing.service.FilmService;import com.duing.vo.FilmVo;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;import java.util.List;@Controllerpublic class FilmController { @Autowired private FilmService filmService; @RequestMapping("/filmList") @ResponseBody public List
selectAll(){ List
filmVos = filmService.selectAll();
return filmVos; }}
daoLayer interface information
package com.duing.dao;import com.duing.entity.Film;import java.util.List;public interface FilmDao { List
getList
();}
Mapping class information
package com.duing.entity;import java.io.Serializable;import java.util.Date;// 实体类 Map with database tablespublic class Film implements Serializable { private static final long serialVersionUID = -4427069375523038931L; private long id; private String film_id; private String name; private String director; private String player; private String type; private String country; private int length; private String synopsis; private Date play_time; private String img_path; public long getId() { return id; } public void setId(long id) { this.id = id; } public String getFilm_id() { return film_id; } public void setFilm_id(String film_id) { this.film_id = film_id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDirector() { return director; } public void setDirector(String director) { this.director = director; } public String getPlayer() { return player; } public void setPlayer(String player) { this.player = player; } public String getType() { return type; } public void setType(String type) { this.type = type; } public String getCountry() { return country; } public void setCountry(String country) { this.country = country; } public int getLength() { return length; } public void setLength(int length) { this.length = length; } public String getSynopsis() { return synopsis; } public void setSynopsis(String synopsis) { this.synopsis = synopsis; } public Date getPlay_time() { return play_time; } public void setPlay_time(Date play_time) { this.play_time = play_time; } public String getImg_path() { return img_path; } public void setImg_path(String img_path) { this.img_path = img_path; }}
service层接口
package com.duing.service;import com.duing.vo.FilmVo;import java.util.List;public interface FilmService { List
selectAll
();}
service层类
package com.duing.service.impl;import com.duing.dao.FilmDao;import com.duing.entity.Film;import com.duing.service.FilmService;import com.duing.vo.FilmVo;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import java.util.ArrayList;import java.util.List;@Servicepublic class FilmServiceimpl implements FilmService { @Autowired private FilmDao filmDao; @Override public List
selectAll
() { List
films = filmDao.getList(); System.out.println(
"Number of database videos"+films.size()); List
result=
new
ArrayList<>();
for (Film film : films) { FilmVo vo=
new
FilmVo(); vo.setFilmId(film.getFilm_id()); vo.setName(film.getName()); vo.setDirector(film.getDirector()); vo.setImgpath(film.getImg_path()); result.add(vo); }
return result; }}
视图层vo
package com.duing.vo;// 视图层对象 Used to display to userspublic class FilmVo { private String filmId; private String name; private String director; private String imgpath; public String getFilmId() { return filmId; } public void setFilmId(String filmId) { this.filmId = filmId; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDirector() { return director; } public void setDirector(String director) { this.director = director; } public String getImgpath() { return imgpath; } public void setImgpath(String imgpath) { this.imgpath = imgpath; }}
mapper配置信息
package com.duing.vo;// 视图层对象 Used to display to userspublic class FilmVo { private String filmId; private String name; private String director; private String imgpath; public String getFilmId() { return filmId; } public void setFilmId(String filmId) { this.filmId = filmId; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getDirector() { return director; } public void setDirector(String director) { this.director = director; } public String getImgpath() { return imgpath; } public void setImgpath(String imgpath) { this.imgpath = imgpath; }}
mybtis配置信息
configuration PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd"><configuration> <mappers> <package name="com.duing.dao"/>
mappers>
configuration>
spring配置信息
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:p="http://www.springframework.org/schema/p" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/tx https://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<context:component-scan base-package="com.duing.service"/>
<context:property-placeholder location="classpath:druid.properties"/>
<bean id="datasource" class="com.alibaba.druid.pool.DruidDataSource"> <property name="url" value="${jdbc.url}"/> <property name="username" value="${jdbc.username}"/> <property name="password" value="${jdbc.password}"/>
bean>
<bean id="factory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="datasource"/> <property name="configLocation" value="classpath:/mybatis.xml"/>
<property name="mapperLocations" value="classpath:mappers/*.xml"/>
bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="sqlSessionFactoryBeanName" value="factory"/> <property name="basePackage" value="com.duing.dao"/>
bean>
beans>
springmvc配置信息
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd">
<context:component-scan base-package="com.duing.controller"/>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <property name="prefix" value="/WEB-INF/jsp/"/> <property name="suffix" value=".jsp"/>
bean>
<mvc:annotation-driven/> <context:annotation-config/>
beans>
druid.properties信息
jdbc.url=jdbc://mysql://localhost:3306/ssm?characterEncoding=utf8jdbc.username=rootjdbc.password=root
pom.xml信息
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0
modelVersion> <groupId>com.duing
groupId> <artifactId>ssm-duing-ticket
artifactId> <version>1.0-SNAPSHOT
version> <packaging>war
packaging> <name>ssm-duing-ticket Maven Webapp
name>
<url>http://www.example.com
url> <properties> <project.build.sourceEncoding>UTF-8
project.build.sourceEncoding> <maven.compiler.source>1.7
maven.compiler.source> <maven.compiler.target>1.7
maven.compiler.target>
properties> <dependencies> <dependency> <groupId>junit
groupId> <artifactId>junit
artifactId> <version>4.11
version> <scope>test
scope>
dependency>
<dependency> <groupId>org.springframework
groupId> <artifactId>spring-context
artifactId> <version>5.2.12.RELEASE
version>
dependency>
<dependency> <groupId>org.springframework
groupId> <artifactId>spring-tx
artifactId> <version>5.2.12.RELEASE
version>
dependency>
<dependency> <groupId>org.springframework
groupId> <artifactId>spring-webmvc
artifactId> <version>5.2.12.RELEASE
version>
dependency>
<dependency> <groupId>org.mybatis
groupId> <artifactId>mybatis
artifactId> <version>3.5.6
version>
dependency>
<dependency> <groupId>org.springframework
groupId> <artifactId>spring-jdbc
artifactId> <version>5.2.12.RELEASE
version>
dependency>
<dependency> <groupId>org.mybatis
groupId> <artifactId>mybatis-spring
artifactId> <version>2.0.6
version>
dependency>
<dependency> <groupId>mysql
groupId> <artifactId>mysql-connector-java
artifactId> <version>8.0.22
version>
dependency>
<dependency> <groupId>com.alibaba
groupId> <artifactId>druid
artifactId> <version>1.2.4
version>
dependency>
<dependency> <groupId>javax.servlet
groupId> <artifactId>javax.servlet-api
artifactId> <version>4.0.1
version> <scope>provided
scope>
dependency>
<dependency> <groupId>javax.servlet.jsp
groupId> <artifactId>jsp-api
artifactId> <version>2.2
version> <scope>provided
scope>
dependency>
<dependency> <groupId>com.fasterxml.jackson.core
groupId> <artifactId>jackson-core
artifactId> <version>2.12.1
version>
dependency> <dependency> <groupId>com.fasterxml.jackson.core
groupId> <artifactId>jackson-databind
artifactId> <version>2.12.1
version>
dependency>
dependencies> <build> <finalName>ssm-duing-ticket
finalName> <pluginManagement>
<plugins> <plugin> <artifactId>maven-clean-plugin
artifactId> <version>3.1.0
version>
plugin>
<plugin> <artifactId>maven-resources-plugin
artifactId> <version>3.0.2
version>
plugin> <plugin> <artifactId>maven-compiler-plugin
artifactId> <version>3.8.0
version>
plugin> <plugin> <artifactId>maven-surefire-plugin
artifactId> <version>2.22.1
version>
plugin> <plugin> <artifactId>maven-war-plugin
artifactId> <version>3.2.2
version>
plugin> <plugin> <artifactId>maven-install-plugin
artifactId> <version>2.5.2
version>
plugin> <plugin> <artifactId>maven-deploy-plugin
artifactId> <version>2.8.2
version>
plugin>
plugins>
pluginManagement>
build>
project>
包结构
边栏推荐
- Hand rolled architecture, 41 Redis interview asked
- 数据湖(二):什么是Hudi
- WebUI自动化测试框架搭建从0到1(完整源码)更新完毕
- Solve the problem of Chinese garbled characters in exporting excel file names
- Process finished with exit code 1
- 借小程序容器打造自有App小程序生态
- Likou 58 - Left Rotation String
- SuperSlide系列之轮播图
- Jest 测试框架 beforeEach 的设计原理解析
- Swift中什么时候不能用 () 代替 Void 来使用
猜你喜欢
随机推荐
zabbix自动化监控脚本
内存存储结构
今日睡眠质量记录85分
Hand rolled architecture, 41 Redis interview asked
看我如何用多线程,帮助运营小姐姐解决数据校对系统变慢!
Failure Analysis | A SELECT statement crashes MySQL, what happened?
Leek 151 - Reverse words in a string
力扣58-左旋转字符串
智能图像分析-智能家用电器图像目标检测统计计数检测与识别-艾科瑞特科技(iCREDIT)
[kali-information collection] (1.8) ARP reconnaissance tool _Netdiscover
When not to use () instead of Void in Swift
Process finished with exit code 1
【Acunetix-忘记密码】
使用kubesphere图形界面创建一个devops的CI/CD流程
1.3 Rapid Spanning Tree Protocol RSTP
解决anaconda下载pytorch速度极慢的方法
基于深度学习的裂缝检测技术
SQL函数 $TRANSLATE
MyCat2的介绍与安装以及基本使用
面积曲线AUC(area under curve)