猿问

SSM一条整的sql语句传入报错

一条整的sql语句传入报错,想搞懂这个问题的原因,

方法:

public List<daily_defray_total> complexSqlQuery(String sql){ 
return ddtMapper.complexSqlQuery(sql);
}

这里传入整条sql:

String defrayTotalSql = " SELECT * FROM daily_defray_total ";
    List<daily_defray_total> dailyDefrayTotalList = dailyDefrayTotalMapper.complexSqlQuery(defrayTotalSql);

在xml文件里 ,1和2都试过
1
<select id="complexSqlQuery" resultMap="BaseResultMap"parameterType="String"> #{0}
</select>

2
<select id="complexSqlQuery" resultMap="BaseResultMap" parameterType="java.lang.String"> #{sql,jdbcType=VARCHAR}
</select>

报错

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 '' SELECT * FROM daily_defray_total '' at line 1


侃侃无极
浏览 1174回答 2
2回答

元芳怎么了

1.我没有见过参数类型是String,貌似只有java.lang.String.2.传递参数你要给用一个参数来接收.

largeQ

SQL语句不用*号,用表的字段,String defrayTotalSql = " SELECT u_id FROM daily_defray_total ";<select id="complexSqlQuery"resultMap="BaseResultMap"parameterType="String">&nbsp;${value}</select>
随时随地看视频慕课网APP
我要回答