Java 操作SQLSERVER数据库进行update,执行错误,语句如下,请高手指教
StringinsertSQL="INSERTINTOtbSmsSendedVALUES("+gId+","+gPhoneCode+","+gSmsType+","+gS...
String insertSQL = "INSERT INTO tbSmsSended VALUES ("+gId+","+gPhoneCode+","+gSmsType+","+gSmsContent+","+gCreateTime+","+gSendTime+","+gSendState+")";
String updataSQL = "UPDATA tbSmsSended SET "+"Id='"+gId+"',"+"PhoneCode='"+gPhoneCode+"',"+"SmsType='"+gSmsType+"',"+"SmsContent='"+gSmsContent+"',"+"CreateTime='"+gCreateTime+"',"+"SendTime='"+gSendTime+"',"+"SendState='"+gSendState+"'";
错误:com.microsoft.sqlserver.jdbc.SQLServerException: '=' 附近有语法错误。
com.microsoft.sqlserver.jdbc.SQLServerException: 'Id' 附近有语法错误。 展开
String updataSQL = "UPDATA tbSmsSended SET "+"Id='"+gId+"',"+"PhoneCode='"+gPhoneCode+"',"+"SmsType='"+gSmsType+"',"+"SmsContent='"+gSmsContent+"',"+"CreateTime='"+gCreateTime+"',"+"SendTime='"+gSendTime+"',"+"SendState='"+gSendState+"'";
错误:com.microsoft.sqlserver.jdbc.SQLServerException: '=' 附近有语法错误。
com.microsoft.sqlserver.jdbc.SQLServerException: 'Id' 附近有语法错误。 展开
展开全部
孩子,建议使用preparedstatement 的jdk5特性 可变参数用 ?代替,避免错误
String insertSQL = "INSERT INTO tbSmsSended(Id,PhoneCode,SmsType,SmsContent,CreateTime,SendTime,SendState) VALUES ('"+gId+"','"+gPhoneCode+"','"+gSmsType+"','"+gSmsContent+"','"+gCreateTime+"','"+gSendTime+"','"+gSendState+"')";
String updataSQL = "UPDATE tbSmsSended SET Id='"+gId+"', PhoneCode='"+gPhoneCode+"', SmsType='"+gSmsType+"', SmsContent='"+gSmsContent+"', CreateTime='"+gCreateTime+"', SendTime='"+gSendTime+"', SendState='"+gSendState+"'";
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询