简体   繁体   English

我如何在Java中将整数值转换为字符串值

[英]How i convert integer value into string value in java

String doc = String.valueOf(po.get_Value("DocumentNo"));

I used above code but still it's taking the integer value in the query. 我使用了上面的代码,但仍然在查询中使用整数值。 Below I mentioned the query where I want the String value. 下面我提到了我想要String值的查询。

String sql = "update C_partial SET IsExported = 'Y' where documentno ="+doc;

Use PreparedStatement 使用PreparedStatement

String sql = "update C_partial SET IsExported = 'Y' where documentno =?";

PreparedStatement stmt = connection.prepareStatement(sql);
stmt.setString(1, doc);

It is just safer and cleaner 更安全更清洁

You can use 您可以使用

String.valueof();

like this and add ' to your query 像这样并在您的查询中添加'

String sql = "update C_partial SET IsExported = 'Y' where documentno = '"+String.valueOf(doc) +"'";

您需要用撇号换行

String sql = "update C_partial SET IsExported = 'Y' where documentno = '"+doc+"'";

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM