Lina
Lina

Reputation: 315

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 sql = "update C_partial SET IsExported = 'Y' where documentno ="+doc;

Upvotes: 1

Views: 377

Answers (3)

Sleiman Jneidi
Sleiman Jneidi

Reputation: 23329

Use 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

Upvotes: 4

glethien
glethien

Reputation: 2471

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) +"'";

Upvotes: 0

Ugur Basak
Ugur Basak

Reputation: 317

You need to wrap with apostrophe characters

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

Upvotes: 0

Related Questions