Not able to use insert sql query in jdbc_streaming filter

When I tried to insert some in local mysql using jdbc_streaming filter, it is showing following error. But no error is shown for select statements.
Ruby-0-Thread-12@[main]>worker6: :1] jdbcstreaming - Exception when executing JDBC query {:exception=>#<Sequel::DatabaseError: Java::JavaSql::SQLException: Can not issue data manipulation statements with executeQuery().>}.

Following is the realted part of my configuration file

jdbc_streaming {
		jdbc_driver_library => "${MYSQL_DRIVER_PATH}"
		jdbc_driver_class => "${JDBC_DRIVER}"
		jdbc_connection_string => "${JDBC_CONNECTION_STRING}"
		jdbc_user => "${DB_USERNAME}"
		jdbc_password => "${DB_PASSWORD}"
		statement => "INSERT INTO rcyc_audit(job_id, process_name, description) VALUES(job_id, process_name, description);"
		parameters => { "jobId" => "jobId"
						"process" => "process"
						"description" => "@metadata[RegionStarted]"
					}
		target => "audit_id"
	}

Apparently the jdbc_streaming filter executes an executeQuery call to the jdbc driver. An executeQuery call executes a query that returns a ResultSet. An executeUpdate call should be used to do an INSERT or other call that does not return a ResultSet. Some drivers enforce this distinction, some do not. For example, the last time I checked (which was nearly 20 years ago) Sybase did not care but DB2 did.

Thanks for your feedback.. But how can I make executeUpdate call inside jdbc_streaming filter? Please help. I'm new to logstash.

I do not think that is supported. The filter is documented as "executes a SQL query and store the result set".

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.