这样来做:
String strSqlTemp = "select * from whz_worktime where start_time=?";
以strSqlTemp 为参数
用Connection 的public PreparedStatement prepareStatement(String sql)
                                   throws SQLException方法
得到PreparedStatement,然后再用PreparedStatement的方法
public void setTimestamp(int parameterIndex,
                         Timestamp x)
                  throws SQLException
来设置条件。

解决方案 »

  1.   

    简单的代码象这样:
    try{
          String strSqlTemp = "select * from whz_worktime where start_time=?";
          PreparedStatement sql = cnYourConInitedBefore.prepareStatement(strSqlTemp)
          Timestamp ts1 = new Timestamp(nYourLongTime);//nYourLongTime inited before!
          sql.setTimestamp(1,ts1);
          ResultSet stRet = stmtYourStateMentWithConnection.executeQuery(sql);// stmtYourStateMentWithConnection inited before!
          //do something here with stRet:
          //....
    }catch(IOException e) {
          e.printStackTrace();
    }
    供参考哈!
      

  2.   

    sorry!
    PreparedStatement sql = cnYourConInitedBefore.prepareStatement(strSqlTemp)
    这句该有分号;
    PreparedStatement sql = cnYourConInitedBefore.prepareStatement(strSqlTemp);
      

  3.   

    谢谢!!但不知
    cnYourConInitedBefore
    是什么??盼复!!!
      

  4.   

    知了!!!
    THANKS!!!!
    马上给分,稍等!!
      

  5.   

    cnYourConInitedBefore 指的是你在此之前得到一个数据库的连接,是一个Connection。
    象这样一个例子可以得到的:
    Class.forName(strDBDriver);
    Connection cnYourConInitedBefore = DriverManager.getConnection(strDBUrl , strDBUser,strDBPassword);
    其中:
    1 strDBDriver 是你所用的数据库的odbc  Driver ,如oracle的 "oracle.jdbc.driver.OracleDriver"
    2 strDBUrl 你的数据库的url,如 "jdbc:oracle:thin:@100.100.0.100:1521:yourBaseName"
    3 strDBUser 是对数据库的用户名,如 "yourName"
    4 strDBPassword 是对数据库针对用户strDBUser 的密码,如 "yourPassWord"