[英]Exception. Not retrying {:exception=>#<Java::OrgPostgresqlUtil::PSQLException: ERROR: syntax error at or near "%"
I want to Add My CSV File to postgreSQL.but whenever i try to connect it Show Error:我想将我的 CSV 文件添加到 postgreSQL。但每当我尝试连接它时显示错误:
[ERROR][logstash.outputs.jdbc
[错误][logstash.outputs.jdbc
][main][a4f714a30e2d2cae8e83b3c2d215c3537fe40dca0495ca92cc2f50a93ba8088a] JDBC - Exception.][main][a4f714a30e2d2cae8e83b3c2d215c3537fe40dca0495ca92cc2f50a93ba8088a] JDBC - 异常。 Not retrying {:exception=>#<Java::OrgPostgresqlUtil::PSQLException: ERROR: syntax error at or near "%"
不重试 {:exception=>#<Java::OrgPostgresqlUtil::PSQLException: ERROR: syntax error at or near "%"
it is My Config.conf File:这是我的 Config.conf 文件:
input {
file {
path => "C:/Users/Desktop/InputData12.csv"
start_position => "beginning"
codec => plain
}
}
filter {
csv {
separator => ","
columns => ["inputdata","metric","source_table","output_column_alias","method"]
}
}
output {
jdbc {
connection_string => "jdbc:postgresql://hostname:5432/database"
username => "username"
password => "password"
driver_jar_path => "C:/Users/Downloads/lib/postgresql-42.5.1.jar"
driver_class => "org.postgresql.Driver"
statement => "INSERT INTO csv_to_postgresql (inputdata,metric,source_table,output_column_alias,method) VALUES (%{inputdata},%{metric},%{source_table},%{output_column_alias},%{method})"
}
}
I would expect that to get a different error (JDBC - Statement has no parameters).我希望得到不同的错误(JDBC - 语句没有参数)。 There are two types of statement.
有两种类型的声明。 If you set "unsafe_statement => true" then the output will sprintf the SQL statement .
如果设置“unsafe_statement => true”,则 output 将sprintf SQL 语句。 If you do not set that then you should be using
如果你没有设置,那么你应该使用
statement => [
"INSERT INTO csv_to_postgresql (inputdata,metric,source_table,output_column_alias,method) VALUES (?, ?, ?, ?, ?)",
"%{inputdata}",
"%{metric}",
"%{source_table}",
"%{output_column_alias}",
"%{method})"
]
in which case the output will sprintf all the parameters to the statement.在这种情况下,output 将sprintf 语句的所有参数。 Setting unsafe_statement can be more expensive than the second approach.
设置 unsafe_statement 可能比第二种方法更昂贵。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.