Not writing code for a long time. The ability to do a lot of the usual errors or frequent occurrences, vomiting blood today.
Simple pits always have to jump a few times to be reconciled. Very clear remember when the university in this pit almost suffocated, and now jumped into this hole, engaged in a long time finally know where the wrong.
= "insert into Cryptcontent (content,assistentcontent) value ('asf', 'asfd') ";D bhelper.insertquery (sqlString);
This operation is possible. Therefore the placeholder should also be fine, assuming that the placeholder is used correctly. The code is as follows (wrong):
= String.Format ( "insert into cryptcontent (content,assistentcontent)" Value (% s,%s) ", assistantencryptresultstring, valuestring); Dbhelper.insertquery (sqlString);
At this time how to debug all error, and then debug, error is as follows:
Com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException:Unknown column ' Afsdf ' in ' Field list '
Debug Debug appears: INSERT into Cryptcontent (content,assistentcontent) value (AFSDF,ASFASFD)
Error found: Note that the field value of the varchar type column in the following value does not have single quotation marks. So FIX:
= String.Format ( "insert into Cryptcontent (content,assistentcontent) value (' %s','%s'), assistantencryptresultstring, valuestring);
Dbhelper.insertquery (sqlString);
Then the execution succeeds.
use of Java string Formatting-string.format ()
Spit Groove MySQL Database jdbc operation, varchar type placeholder problem-single quote Commit