简体   繁体   English

例外。 不重试 {:exception=># <java::orgpostgresqlutil::psqlexception: error: syntax error at or near "%"< div><div id="text_translate"><p> 我想将我的 CSV 文件添加到 postgreSQL。但每当我尝试连接它时显示错误:</p><blockquote><p> [错误][logstash.outputs.jdbc<br> ][main][a4f714a30e2d2cae8e83b3c2d215c3537fe40dca0495ca92cc2f50a93ba8088a] JDBC - 异常。 不重试 {:exception=>#<Java::OrgPostgresqlUtil::PSQLException: ERROR: syntax error at or near "%"</p></blockquote><p> 这是我的 Config.conf 文件:</p><pre> 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})" } }</pre></div></java::orgpostgresqlutil::psqlexception:>

[英]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.

相关问题 错误:index_not_found_exception - Error: index_not_found_exception java异常的GROK模式 - GROK patterns for java exception 如何修复此代码异常错误elasticsearch - how to fix this code exception error elasticsearch 如何为远程日志记录的异常错误配置rsyslog模板? - How to configure rsyslog template for Exception error for remote logging? 发生聚合异常{:ERROR=&gt;#<NoMethodERROR: undefined method `-’ for nil:NilClass> - Aggregate exception occurred {:ERROR=>#<NoMethodERROR: undefined method `-’ for nil:NilClass> 正则表达式java异常排除“由:”引起 - regex java exception exclude “Caused by:” Logstash无输出-错误,无法检索cgroups信息{:exception =&gt;“ NoMethodError” - Logstash No output - Error, cannot retrieve cgroups information {:exception=>“NoMethodError” 由于批量上传错误,无法上传到 Elasticsearch 集群时,logstash 不断重试 - logstash keeps retrying infinitely when failed to upload to Elasticsearch cluster due to bulk upload error 这个logstash错误的原因是什么(“error”=&gt;{“type”=&gt;“illegal_argument_exception”,“reason”=&gt;“mapper) - what is the reason for this logstash error("error"=>{"type"=>"illegal_argument_exception", "reason"=>"mapper) 这个logstash错误的原因是什么:exception=&gt;#&lt; &quot;LogStash&quot; ::Json::ParserError: Unexpected end-of-input in VALUE_STRING - what is the reason for this logstash error : exception=>#< "LogStash" ::Json::ParserError: Unexpected end-of-input in VALUE_STRING
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM