I want to Add My CSV File to postgreSQL.but whenever i try to connect it Show Error:
[ERROR][logstash.outputs.jdbc
][main][a4f714a30e2d2cae8e83b3c2d215c3537fe40dca0495ca92cc2f50a93ba8088a] JDBC - Exception. Not retrying {:exception=>#<Java::OrgPostgresqlUtil::PSQLException: ERROR: syntax error at or near "%"
it is My Config.conf File :
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). There are two types of statement. If you set "unsafe_statement => true" then the output will sprintf the SQL statement. If you do not set that then you should be using
in which case the output will sprintf all the parameters to the statement. Setting unsafe_statement can be more expensive than the second approach.