1
我试图执行一个常规的SQL在蚂蚁从Ant属性中常规使用SQL数据库schema名称
<target name="groovy_sql">
<groovy>
import groovy.sql.Sql
def sql = Sql.newInstance(properties."master.jdbc_connection_string", properties."master.database_user", properties."master.database_password", "net.sourceforge.jtds.jdbc.Driver")
def table = '['+properties."app.database_name"+']..FILE_DATA'
def row = sql.firstRow("SELECT top 1 id from ${table} order by id desc")
properties."fileDataId" = row[0]
</groovy>
<echo message="fileDataId: ${fileDataId}"/>
</target>
选择如下而我得到以下错误
[groovy] Sep 04, 2015 2:16:14 PM groovy.sql.Sql$AbstractQueryCommand execute
[groovy] WARNING: Failed to execute: SELECT top 1 id from ? order by id desc because: Must declare the table variable "@P0".
我想这个原因错误是表名不能作为参数传递。 由于此脚本必须在不同的环境中运行,因此我们在不同的环境中使用不同的模式,因此我无法对模式名称进行硬编码,而且我很难找出解决方案。有人可以帮我解决这个问题吗?