我在写sql语句时,加入了一个时间为当前,但是就是用now() ,为什么报 下面这样的错误呢?
### Error updating database. Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'out_trade_no )
values ( now()
' at line 1
### The error may involve com.hnsaturn.saturn005.dao.PayDao.addGOrder-Inline
### The error occurred while setting parameters
### SQL: ( out_trade_no ) values ( now() ? )
### Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'out_trade_no )
values ( now()
' at line 1
; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'out_trade_no )
values ( now()
' at line 1] with root cause
java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'out_trade_no )
values ( now()
java代码
GOrder gOrder = new GOrder();
gOrder.setOutTradeNo(orderString);
payDao.addGOrder(gOrder);
实体类
@Data
@Builder
@EntityScan
public class GOrder implements Serializable {
public int id,gNumber;//订单Id、商品号
//商品号、商户订单号、支付宝交易号、支付金额、支付时间
public String gName,price,outTradeNo,tradeNo,totalAmount,gmtPayment;
private Integer uId,tradeStatus;//用户Id、交易状态(0未支付1已支付)
private Date oTime;//订单提交时间
@Tolerate
public GOrder(){}
}
下面是sql 语句
<!--存入支付宝订单信息-->
<insert id="addGOrder" parameterType="隐藏路径了.GOrder">
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null and id !=''" >
id,
</if>
<if test="gName != null and gName !=''">
g_name,
</if>
<if test="gNumber != null and gNumber !=''">
g_number,
</if>
<if test="price != null and price !=''">
price,
</if>
<if test="oTime != null and oTime !=''">
o_time,
</if>
<if test="uId != null and uId !=''">
u_id,
</if>
<if test="outTradeNo != null and outTradeNo !=''">
out_trade_no,
</if>
<if test="tradeNo != null and tradeNo !=''">
trade_no,
</if>
<if test="totalAmount != null and totalAmount !=''">
total_amout,
</if>
<if test="gmtPayment != null and gmtPayment !=''">
gmt_payment,
</if>
<if test="tradeStatus != null and tradeStatus !=''">
trade_status,
</if>
</trim>
<trim prefix=" values (" suffix=")" suffixOverrides=",">
<if test="id != null and id !=''">
#{id},
</if>
<if test="gName != null and gName !=''">
#{gName},
</if>
<if test="gNumber != null and gNumber !=''">
#{gNumber},
</if>
<if test="price != null and price !=''">
#{price},
</if>
now(),
<if test="uId != null and uId !=''">
#{uId},
</if>
<if test="outTradeNo != null and outTradeNo !=''">
#{outTradeNo},
</if>
<if test="tradeNo != null and tradeNo !=''">
#{tradeNo},
</if>
<if test="totalAmount != null and totalAmount !=''">
#{totalAmount},
</if>
<if test="gmtPayment != null and gmtPayment !=''">
#{gmtPayment},
</if>
<if test="tradeStatus != null and tradeStatus !=''">
#{tradeStatus},
</if>
</trim>
</insert>