什么是preferred方式,以避免SQL注入的火花SQL(上蜂巢) [英] What is the preferred way to avoid SQL injections in Spark-SQL (on Hive)

查看:132
本文介绍了什么是preferred方式,以避免SQL注入的火花SQL(上蜂巢)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设一个SchemaRDD RDD ,注册表格客户。您想要根据用户输入来过滤掉的记录。你可能有如何做到这一点的一个想法是:

Assume a SchemaRDD rdd with a registered table customer. You want to filter out records according to a user input. One idea you might have how to do this is the following:

rdd.sqlContext.sql(s"SELECT * FROM customer WHERE name='$userInput'")

然而,由于PHP的旧时代,我们知道,这可能会导致讨厌的东西。
有preparedStatement的等效?我能找到的,看起来远程相关的唯一事情是 org.apache.commons.lang.StringEscapeUtils.escapeSql

推荐答案

一个选择是使用 thriftserver揭露JDBC 的,然后可以使用通常的技术(preparedStatement等等)到prevent SQL注入

One option would be to use the thriftserver to expose jdbc, and then the usual techniques could be used (PreparedStatement etc.) to prevent sql injection.

这篇关于什么是preferred方式,以避免SQL注入的火花SQL(上蜂巢)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆