JDBC驱动程序需要Java 8.我当前正在运行Java 7.我能够在EC2实例上安装另一个版本的Java.
https://tecadmin.net/install-java-8-on-centos-rhel-and-fedora/#
我还必须在我的代码中设置java版本.通过这些更改,代码现在可以按预期运行.
from mdpbi.rsi.config import * from mdpbi.tools.functions import mdpLog from pkg_resources import resource_string import argparse import os import pyathenajdbc import sys SCRIPT_NAME = "Athena_Export" def get_arg_parser(): """This function returns the argument parser object to be used with this script""" parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) return parser def main(): args = get_arg_parser().parse_args(sys.argv[1:]) logger = mdpLog(SCRIPT_NAME, LOGDIR) SQL = resource_string("mdpbi.rsi.athena.resources", "athena.sql") os.environ["JAVA_HOME"] = "/opt/jdk1.8.0_121" os.environ["JRE_HOME"] = "/opt/jdk1.8.0_121/jre" os.environ["PATH"] = "/opt/jdk1.8.0_121/bin:/opt/jdk1.8.0_121/jre/bin" conn = pyathenajdbc.connect( s3_staging_dir="s3://mdpbi.data.rsi.out/", access_key=AWS_ACCESS_KEY_ID, secret_key=AWS_SECRET_ACCESS_KEY, schema_name="rsi", region_name="us-east-1" ) try: with conn.cursor() as cursor: cursor.execute(SQL) logger.info(cursor.description) logger.info(cursor.fetchall()) finally: conn.close() return 0 if __name__ == '__main__': rtn = main() sys.exit(rtn)