java中字符串的快速参数函数
我是delphi程序员,很久以前就使用过Java,现在再次回到java项目中,我确信有一个函数或对象可以用来基本上创建一个带有参数的字符串,并且可以替换所述参数就像PreparedStatement一样。现在我一生都记不起这个函数叫什么,或者即使它存在于PreparedStatement之外还是我在想象事情???
例如,我想采用这样的字符串:
String ss = "(CODE, CATEGEORY, DESCRIPTION) VALUES (:CODE, :CATEGEORY, :DESCRIPTION)";
并且能够做到这一点
ss.setParam(0, "thisValue");
ss.setParam(1, "thus_value");
等等......
任何想法
Im delphi programmer and used to use Java quite a bit a long while ago and now back onto a project in java again and im sure that there was a function or object that could be used to basically create a string with parameters and would replace said params just like PreparedStatement. Now for the life of me i cannot remember what this function is called or even if it exists outside of PreparedStatement or am i imagining things ???
For example, i want to take a string like this:
String ss = "(CODE, CATEGEORY, DESCRIPTION) VALUES (:CODE, :CATEGEORY, :DESCRIPTION)";
and be able to do this
ss.setParam(0, "thisValue");
ss.setParam(1, "thus_value");
etc...
Any ideas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你是对的,它们被称为PreparedStatements。
http://download.oracle.com/javase/6 /docs/api/java/sql/PreparedStatement.html
You are right, they are called PreparedStatements.
http://download.oracle.com/javase/6/docs/api/java/sql/PreparedStatement.html
您在谈论“StringBuffer”吗?如果是,您只需将查询附加到其中并创建查询即可。
Are you talking about 'StringBuffer' ? If yes, you can simply append your query to it and create a query.