我正在尝试从我的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笔记本时,一切都很好