Databrick pyspark:Py4JJavaError:调用o675.load时发生错误

时间:2017-07-12 10:28:28

标签: mysql apache-spark pyspark databricks

我尝试使用Databrick pyspark将mysql表加载到spark中

以下代码

dataframe_mysql = sqlContext.read.format("jdbc").option("url", "jdbc:mysql://dns:3306/stats")
                                                .option("driver", "com.mysql.jdbc.Driver")
                                                .option("dbtable", "usage_facts")
                                                .option("user", "root")
                                                .option("password", "password").load()

收到以下错误:

    ---------------------------------------------------------------------------
Py4JJavaError                             Traceback (most recent call last)
<ipython-input-24-967ec26b4f21> in <module>()
----> 1 dataframe_mysql = sqlContext.read.format("jdbc").option("url", "jdbc:mysql://dns:3306/stats").option("driver", "com.mysql.jdbc.Driver").option("dbtable", "usage_facts").option("user", "root").option("password", "password").load()

/databricks/spark/python/pyspark/sql/readwriter.py in load(self, path, format, schema, **options)
    153             return self._df(self._jreader.load(self._spark._sc._jvm.PythonUtils.toSeq(path)))
    154         else:
--> 155             return self._df(self._jreader.load())
    156 
    157     @since(1.4)

/databricks/spark/python/lib/py4j-0.10.4-src.zip/py4j/java_gateway.py in __call__(self, *args)
   1131         answer = self.gateway_client.send_command(command)
   1132         return_value = get_return_value(
-> 1133             answer, self.gateway_client, self.target_id, self.name)
   1134 
   1135         for temp_arg in temp_args:

/databricks/spark/python/pyspark/sql/utils.py in deco(*a, **kw)
     61     def deco(*a, **kw):
     62         try:
---> 63             return f(*a, **kw)
     64         except py4j.protocol.Py4JJavaError as e:
     65             s = e.java_exception.toString()

/databricks/spark/python/lib/py4j-0.10.4-src.zip/py4j/protocol.py in get_return_value(answer, gateway_client, target_id, name)
    317                 raise Py4JJavaError(
    318                     "An error occurred while calling {0}{1}{2}.\n".
--> 319                     format(target_id, ".", name), value)
    320             else:
    321                 raise Py4JError(

Py4JJavaError: An error occurred while calling o675.load.
: java.sql.SQLException: Access denied for user 'root'@'dns' (using password: YES)
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1078)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4237)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4169)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:928)
    at com.mysql.jdbc.MysqlIO.proceedHandshakeWithPluggableAuthentication(MysqlIO.java:1750)
    at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1290)
    at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2493)
    at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2526)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2311)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:834)
    at com.mysql.jdbc.JDBC4Connection.<init>(JDBC4Connection.java:47)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
    at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:416)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:347)
    at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$$anonfun$createConnectionFactory$1.apply(JdbcUtils.scala:59)
    at org.apache.spark.sql.execution.datasources.jdbc.JdbcUtils$$anonfun$createConnectionFactory$1.apply(JdbcUtils.scala:50)
    at org.apache.spark.sql.execution.datasources.jdbc.JDBCRDD$.resolveTable(JDBCRDD.scala:58)
    at org.apache.spark.sql.execution.datasources.jdbc.JDBCRelation.<init>(JDBCRelation.scala:113)
    at org.apache.spark.sql.execution.datasources.jdbc.JdbcRelationProvider.createRelation(JdbcRelationProvider.scala:45)
    at org.apache.spark.sql.execution.datasources.DataSource.resolveRelation(DataSource.scala:320)
    at org.apache.spark.sql.DataFrameReader$$anonfun$load$1.apply(DataFrameReader.scala:154)
    at org.apache.spark.sql.DataFrameReader$$anonfun$load$1.apply(DataFrameReader.scala:148)
    at org.apache.spark.sql.execution.SQLExecution$.withFileAccessAudit(SQLExecution.scala:53)
    at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:147)
    at org.apache.spark.sql.DataFrameReader.load(DataFrameReader.scala:126)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at py4j.reflection.MethodInvoker.invoke(MethodInvoker.java:244)
    at py4j.reflection.ReflectionEngine.invoke(ReflectionEngine.java:357)
    at py4j.Gateway.invoke(Gateway.java:280)
    at py4j.commands.AbstractCommand.invokeMethod(AbstractCommand.java:132)
    at py4j.commands.CallCommand.execute(CallCommand.java:79)
    at py4j.GatewayConnection.run(GatewayConnection.java:214)
    at java.lang.Thread.run(Thread.java:745)

0 个答案:

没有答案