这样来做:
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
来设置条件。
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
来设置条件。
解决方案 »
- 服务器端关闭Socket的疑问
- 如何设置快捷键在JInternalFrame之间进行切换
- 腾讯RTX的2次开发, 自己写发送即时消息的功能, 不是消息提醒哦(JAVA)
- 关于解析ascii码生成的报文的中文问题,急!!!
- applet在显示时显示一个边界,怎么办呢??朋友说加个border,但applet没有border属性啊,请问怎么设置呢??
- 运行成功,可是不是我想要的效果!程序如下:
- 关于netty4中的AttributeKey
- 部署CMP时的错误
- 为什么我的JBuilder7装不了?
- java菜鸟 泛型问题求解
- socket 请教
- 这段代码为什么不能显示INSERT按扭,我点了一下最大化的按扭,可以显示了,感觉是没有刷新,怎么帮?
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();
}
供参考哈!
PreparedStatement sql = cnYourConInitedBefore.prepareStatement(strSqlTemp)
这句该有分号;
PreparedStatement sql = cnYourConInitedBefore.prepareStatement(strSqlTemp);
cnYourConInitedBefore
是什么??盼复!!!
THANKS!!!!
马上给分,稍等!!
象这样一个例子可以得到的:
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"