<i id='2xQe3'><tr id='2xQe3'><dt id='2xQe3'><q id='2xQe3'><span id='2xQe3'><b id='2xQe3'><form id='2xQe3'><ins id='2xQe3'></ins><ul id='2xQe3'></ul><sub id='2xQe3'></sub></form><legend id='2xQe3'></legend><bdo id='2xQe3'><pre id='2xQe3'><center id='2xQe3'></center></pre></bdo></b><th id='2xQe3'></th></span></q></dt></tr></i><div id='2xQe3'><tfoot id='2xQe3'></tfoot><dl id='2xQe3'><fieldset id='2xQe3'></fieldset></dl></div>
        • <bdo id='2xQe3'></bdo><ul id='2xQe3'></ul>

      1. <legend id='2xQe3'><style id='2xQe3'><dir id='2xQe3'><q id='2xQe3'></q></dir></style></legend>

        <small id='2xQe3'></small><noframes id='2xQe3'>

        <tfoot id='2xQe3'></tfoot>
      2. 在 sql 查询中使用 java.sql.Timestamp 对象

        时间:2023-07-25
          <tbody id='Fu761'></tbody>

          <i id='Fu761'><tr id='Fu761'><dt id='Fu761'><q id='Fu761'><span id='Fu761'><b id='Fu761'><form id='Fu761'><ins id='Fu761'></ins><ul id='Fu761'></ul><sub id='Fu761'></sub></form><legend id='Fu761'></legend><bdo id='Fu761'><pre id='Fu761'><center id='Fu761'></center></pre></bdo></b><th id='Fu761'></th></span></q></dt></tr></i><div id='Fu761'><tfoot id='Fu761'></tfoot><dl id='Fu761'><fieldset id='Fu761'></fieldset></dl></div>

            <bdo id='Fu761'></bdo><ul id='Fu761'></ul>
          • <small id='Fu761'></small><noframes id='Fu761'>

            • <tfoot id='Fu761'></tfoot>

                  <legend id='Fu761'><style id='Fu761'><dir id='Fu761'><q id='Fu761'></q></dir></style></legend>
                • 本文介绍了在 sql 查询中使用 java.sql.Timestamp 对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在尝试在 java 中运行一个查询,该查询使用 java.sql.Timestamp 对象作为要在 where 子句中进行比较的日期.

                  I am trying to run a query in java that uses a java.sql.Timestamp object as the date to compare with in the where clause.

                  这是用 Java 构建的查询字符串的方式

                  Here is how the query string that is built in Java

                   String getTransactionsSQL =  "Select transaction_seq " +
                      "From transactions ct " +
                      "Where id = 'ABCD'" + 
                      "And ct.out_msg_timestamp" +
                      "<= to_date('" + parseDate.getTimeStamp() +"','YYYY-MM-DD HH:MI:SS..')" +
                      "order by transaction_seq"; 
                  

                  语句 parseDate.getTimeStamp() 返回一个包含日期的 java.sql.TimeStamp 对象.这是 System.out.println(parseDate.getTimeStamp());

                  The statement parseDate.getTimeStamp() returns a java.sql.TimeStamp object that contains a date. Here is an example output of System.out.println(parseDate.getTimeStamp());

                  2011-03-07 05:47:57.0
                  

                  当我运行上面的查询时,我得到了这个错误

                  When i run the above query i get this error

                   java.sql.SQLException: ORA-01843: not a valid month
                  

                  有什么线索吗?

                  推荐答案

                  使用 PreparedStatement:http://download.oracle.com/javase/6/docs/api/java/sql/PreparedStatement.html

                  Use PreparedStatement: http://download.oracle.com/javase/6/docs/api/java/sql/PreparedStatement.html

                  切勿使用字符串连接将参数传递给 SQL 命令(安全风险:SQL 注入)!

                  Never use string concatenation to pass arguements to SQL commands (security risk: SQL injection)!

                  这篇关于在 sql 查询中使用 java.sql.Timestamp 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:java到mysql.我需要从字符串参数转换为时间戳 下一篇:java中如何将时间戳转换为日期格式

                  相关文章

                  最新文章

                    <legend id='6mlwW'><style id='6mlwW'><dir id='6mlwW'><q id='6mlwW'></q></dir></style></legend>

                      <i id='6mlwW'><tr id='6mlwW'><dt id='6mlwW'><q id='6mlwW'><span id='6mlwW'><b id='6mlwW'><form id='6mlwW'><ins id='6mlwW'></ins><ul id='6mlwW'></ul><sub id='6mlwW'></sub></form><legend id='6mlwW'></legend><bdo id='6mlwW'><pre id='6mlwW'><center id='6mlwW'></center></pre></bdo></b><th id='6mlwW'></th></span></q></dt></tr></i><div id='6mlwW'><tfoot id='6mlwW'></tfoot><dl id='6mlwW'><fieldset id='6mlwW'></fieldset></dl></div>
                      • <bdo id='6mlwW'></bdo><ul id='6mlwW'></ul>

                      <small id='6mlwW'></small><noframes id='6mlwW'>

                      <tfoot id='6mlwW'></tfoot>