String tempUserInformation = null;
// 获取myslq的statement对象
Statement statement = DBStatmentFactory.getStatment(); /**
 * 生成sql语句
 */ StringBuilder CompleteSelfInformation = new StringBuilder(
"update UserSelfInformation set"); // 添加名字插入信息
if ((tempUserInformation = userInformationDoc.getRootElement()
.getChildText("userName")) != null) {
CompleteSelfInformation.append(" userName = " + tempUserInformation
+ " ,");
System.out.println(tempUserInformation);
}  下面是执行
// 处理语句
CompleteSelfInformation.delete(CompleteSelfInformation.length() - 1,
CompleteSelfInformation.length()); CompleteSelfInformation.append("where id = " + userID); System.out.println(CompleteSelfInformation.toString().trim()); /**
 * 执行sql语句
 */
try {
statement.execute(CompleteSelfInformation.toString().trim());
} catch (SQLException e) {
System.out.println("没有修改成功!------------需要反馈到客户端没有修改成功");
e.printStackTrace();
} /**
 * 释放相关链接资源
 */ ReleaseResource.releaseConnectAndStatement(statement);异常是  Unknown column '这里是乱码' in 'field list' 这里的乱码不是csdn的转码问题,另外,我的字符集和mysql的表字符集都是utf - 8,这个到底是怎么回事,请助!!在线等。mysql乱码stringbuilder

解决方案 »

  1.   

    已解决,由于在append字符串的时候,如果仅仅放入对应的字符串对象,那么就是一个实实在在的字符串,而不能表示需要插入的数据,所以解决办法是CompleteSelfInformation.append(" userName = " + "'" + tempUserInformation + "'"
    + " ,");问题解决,由于是第一次使用Java来写数据库语句,所以才会犯了如此低级的错误。另外,送分!40,谁是下一楼谁的。