mysql 存储多媒体数据_Spring boot在MySQL数据库存储多媒体文件信息

该博客介绍了如何使用Spring Boot的JdbcTemplate组件在MySQL数据库中查询和存储多媒体文件信息,包括文件ID、文件名、路径、作者和创建日期等关键字段。
摘要由CSDN通过智能技术生成

创建一个多媒体文件数据查询的Rest web service服务:VideoDBController.java

package image;

import java.sql.Date;

import java.sql.Timestamp;

import java.util.ArrayList;

import java.util.List;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.jdbc.core.JdbcTemplate;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import image.storage.FileInfoBean;

@RestController

public class VideoDBController {

@Autowired

private JdbcTemplate jdbcTemplate;

@RequestMapping("/videoList")

public List getVideoList()

{

String sql = "select * from video_info";

List> resTmp = jdbcTemplate.queryForList(sql);

List result = new ArrayList();

//遍历所有数据

for(Map map:resTmp)

{

FileInfoBean fileInfo =new FileInfoBean();

Object id = map.get("id");

if(id!=null)

{

fileInfo.setId(Integer.valueOf(id.toString()));

}

Object fileName=map.get("fileName");

if(fileName!=null)

{

fileInfo.setFileName(fileName.toString());

}

Object filePath=map.get("filePath");

if(filePath!=null)

{

fileInfo.setFilePath(filePath.toString());

}

Object author=map.get("author");

if(author!=null)

{

fileInfo.setAuthor(author.toString());

}

Object createDate =map.get("createDate");

if(createDate !=null)

{

fileInfo.setCreatedDate((Timestamp)createDate);

}

result.add(fileInfo);

}

return result;

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值