问题描述
例如
public void invoke(String value,SinkFunction.Context context) throws sqlException {
statement_.execute("INSERT INTO test (column_1) VALUES '"+value"');
}
如何正确插入值?
解决方法
获得连接后,您可以执行以下操作:
String sql = "INSERT INTO test (column_1) VALUES (?)";
PreparedStatement statement = connection.prepareStatement(sql);
statement.setString(1,value);
statement.addBatch();
statement.executeBatch();