Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java SQL选择和时间戳列_Java_Mysql_Timestamp - Fatal编程技术网

Java SQL选择和时间戳列

Java SQL选择和时间戳列,java,mysql,timestamp,Java,Mysql,Timestamp,在我的应用程序中,我有一个java时间戳dateCreated,它被插入到mysql时间戳列中。插入没有问题,我使用准备好的语句和语句。setTimestamp(dateCreated) 现在我需要选择一行,其中dateCreated作为唯一标识符。我的方法获取另一个java时间戳对象。在这种情况下SQL查询是如何工作的?我还没有弄清楚如何将java时间戳与mysql时间戳进行比较 从timestamp_column=??? 谢谢 在Java中,您将使用与insert类似的setTimestam

在我的应用程序中,我有一个java
时间戳dateCreated
,它被插入到mysql时间戳列中。插入没有问题,我使用准备好的语句和
语句。setTimestamp(dateCreated)

现在我需要选择一行,其中dateCreated作为唯一标识符。我的方法获取另一个java时间戳对象。在这种情况下SQL查询是如何工作的?我还没有弄清楚如何将java时间戳与mysql时间戳进行比较

从timestamp_column=???


谢谢

在Java中,您将使用与insert类似的setTimestamp方法

   Timestamp t = ???;


   String sql = "SELECT * FROM table WHERE timestamp_column = ?";
   preparedStatement = conn.prepareStatement(sql);
   preparedStatement.setTimestamp(t);

等等。

发布用于执行此查询的Java代码。
private final static String SELECT\u SPEL=“SELECT*FROM SPEL WHERE datumanegmaakt LIKE%d”和进一步的:String.format(SELECT_SPEL,timestamp)我不知道准备好的语句也可以处理SELECT查询。谢谢