【发布时间】:2016-03-17 00:44:39
【问题描述】:
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);
谁能帮我解决这个问题, 我需要查询 mySQL db where date = input in html
【问题讨论】:
-
您似乎遇到了 MySQL 语法错误异常。检查错误信息是否没有打印出实际执行的 SQL 查询。
-
我在 mysql 中使用简单日期数据类型
-
嗨 xaviert,如果在 mysql 中工作正常,请直接查询:select * from tag_data where tag_data_date = '2015-12-11';
-
你能建议我用日期(tag_data_date)在数据库中搜索行的方法
-
AFAIK SQL 查询看起来不错。您是否验证了所有日期解析的输出? (
java.sql.Date.valueOf(date).toString())
标签: mysql tomcat jdbc prepared-statement