我无法在此代码中绑定参数:
import org.influxdb.InfluxDB;
import org.influxdb.InfluxDBFactory;
import org.influxdb.dto.BoundParameterQuery;
import org.influxdb.dto.Query;
import org.influxdb.dto.QueryResult;
public class BindTest {
public static void main(String[] args) {
InfluxDB influxDB = InfluxDBFactory.connect("http://127.0.0.1:8086");
String s = "SELECT LAST(*) FROM batch_assembly_monitoring WHERE last_batch_start = $lbs";
Query query = BoundParameterQuery.QueryBuilder.newQuery(s)
.bind("lbs", 234567890)
.create();
System.out.println(query.getCommand());
QueryResult result = influxDB.query(query);
}
}
我在标准输出得到的输出:
SELECT LAST(*) FROM batch_assembly_monitoring WHERE last_batch_start = $lbs
并且 InfluxDB 日志也包含以下内容:
[httpd] 172.17.0.1 - - [24/Sep/2020:12:40:29 +0000] "POST /query?params=%7B%22lbs%22%3A234567890%7D&q=SELECT+LAST%28%2A%29 +FROM+batch_assembly_monitoring+WHERE+last_batch_start+%3D+%24lbs HTTP/1.1" 200 89"-""okhttp/4.8.1" 20fe610d-fe63-11ea-81ba-0242ac110002 271
似乎绑定参数未绑定,并且在查询中使用占位符字符串而不是值 234567890。
我错了什么?