当前位置:网站首页>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>
包结构
边栏推荐
- Pod Scheduling Strategy: Affinity, Stain and Stain Tolerance
- CCF paper conference IEEE how to query all articles of a conference journal
- Solve the problem of Chinese garbled characters in exporting excel file names
- The ex-boyfriend bought chili water and threatened to rob his daughter. Can the woman apply for a personal safety protection order?
- 主流跨端技术一览
- QAbstractScrollArea、QScrollArea
- AQS-AbstractQueuedSynchronizer
- 商业流程服务BPass你真的了解吗?
- 力扣209-长度最小的字符串——滑动窗口法
- SQL Server 数据库之导入导出数据
猜你喜欢
测试开发之路,我在大厂做测试这四年的感悟
[kali-information collection] (1.9) Metasploit + search engine tool Shodan
NVIDIA NeMo Metrics 轻量性能采集系统
Likou 35 - search for insertion position - binary search
[kali-information collection] (1.8) ARP reconnaissance tool _Netdiscover
Lexicon 27 - Remove Elements - Simple Questions
How to connect TDengine through DBeaver?
使用mosquitto过程中的问题解决
Thymeleaf
Distributed current limiting, hand & redisson implementation
随机推荐
分布式限流利器,手撕&redisson实现
DTG-SSOD:最新半监督检测框架,Dense Teacher(附论文下载)
如何更好评估信用贷风险?看这场评分卡模型直播就可以了
Seneor Exposure Basics
匹配滤波(四种滤波器的幅频特性)
看我如何用多线程,帮助运营小姐姐解决数据校对系统变慢!
基于深度学习的裂缝检测技术
免费文档翻译-免费批量文档翻译软件推荐
主流跨端技术一览
How to set up wireless PPI communication between Weiluntong touch screen and S7-200smart?
MySQL主从复制几个重要的启动选项
[kali-information collection] (1.9) Metasploit + search engine tool Shodan
Speed up your programs with bitwise operations
When not to use () instead of Void in Swift
simulink PID自动整定
Crack detection technology based on deep learning
自己如何做小程序呢?
【MySQL】多表联合查询、连接查询、子查询「建议收藏」
Swiper系列之轮播图
After Effects 教程,如何在 After Effects 中对蒙版进行动画绘制?