如何将值传递给?在java中用单引号括起来
我有一个文本框,用户在其中输入日期,如2013年11月29日 我希望转换以下字符串:如何将值传递给?在java中用单引号括起来,java,Java,我有一个文本框,用户在其中输入日期,如2013年11月29日 我希望转换以下字符串: String sql = "select * from review where creationdate like '?%' order by creationdate desc"; (进入) 使用参数占位符。 如何操作?您需要使用PreparedStatement的设置字符串(位置、值)在占位符处设置值。 String sql = "select * from review where creation
String sql = "select * from review where creationdate like '?%' order by creationdate desc";
(进入)
使用参数占位符。
如何操作?您需要使用
PreparedStatement
的设置字符串(位置、值)
在占位符处设置值。
String sql = "select * from review where creationdate like '?%'
order by creationdate desc";
PreparedStatement pstmt=con.createPreparedStatement(sql);
pstm.setString(1,textbox.getText());
//It will get the value from textbox e.g. 29-NOV-2013
,享受吧!嗨,马苏德,我主要是个C#guy,所以我是noob。我应该如何使用model2@user3053596,你的问题解决了吗?看一下本教程,这里是连接字符串?如何对数据库执行它?嗨,Mik378,我主要是个C#家伙,所以我是noob。如何使用model2执行此函数
String sql = "select * from review where creationdate like '?%'
order by creationdate desc";
PreparedStatement pstmt=con.createPreparedStatement(sql);
pstm.setString(1,textbox.getText());
//It will get the value from textbox e.g. 29-NOV-2013
PreparedStatement pstmt =
con.prepareStatement("select * from review where creationdate like ? order by creationdate desc");
pstmt.setString(1, "29-NOV-2013%")