使用jdbc错误从Flask应用连接蜂巢

时间:2020-04-22 12:45:37

标签: python flask jdbc hive jaydebeapi

我正在尝试从我的flask应用程序连接配置单元数据库,但出现此错误:

java.sql.SQLException: No suitable driver found for jdbc:hive2://myserverspark:10000/default;

这是我的代码:

app = Flask(__name__)

CORS(app)
@app.route('/')
def checkBDD(): 
    database='default'
    driver='org.apache.hive.jdbc.HiveDriver'
    server='myserverspark'
    port=10000
    # JDBC connection string
    url = ("jdbc:hive2://" + server + ":" + str(port)+ "/" + database +";")
    conn=jaydebeapi.connect("org.apache.hive.jdbc.HiveDriver", url,['hive',''])
    print('OK')
    return 'on'

    if __name__ == '__main__':
       jar = "hive-jdbc-standalone.jar"
       args = '-Djava.class.path=%s' % jar
       jvm_path = jpype.getDefaultJVMPath()
       jpype.startJVM(jvm_path, args, '-Djavax.security.auth.useSubjectCredsOnly=false')
       app.run()

注意:当我使用jupyter笔记本时,一切都很好

0 个答案:

没有答案