小编moh*_*rma的帖子

使用preparedStatement.setDate查询MySQL数据库

public java.util.List<Tag> getAlltagsByDate(String date ){

    DataSource dataSource = new DataSource();
    Connection conn = dataSource.createConnection();
    ResultSet resultSet = null;
    PreparedStatement stmt = null;
    Tag tags_Data = new Tag();
    String query = "select * from tag_data where tag_data_date  =  ?";
    try {
        DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
        Date nn  =df.parse(date);
        stmt = conn.prepareStatement(query);
        stmt.setDate(1, java.sql.Date.valueOf(date));
        resultSet = stmt.executeQuery(query);
Run Code Online (Sandbox Code Playgroud)

我收到了一个错误 Tomcat错误

任何人都可以帮我这个,我需要查询mySQL db where date = input in html

在此输入图像描述

mysql tomcat jdbc prepared-statement

13
推荐指数
1
解决办法
326
查看次数

标签 统计

jdbc ×1

mysql ×1

prepared-statement ×1

tomcat ×1