Unable to create connection to database server

pyspark
#1

Hi,

I try to connect a jdbc to create dataframe by the following command.

  1. pyspark --master yarn --conf spark.ui.port=12345 --jars /usr/share/java/mysql-connector-java.jar --driver-class-path /usr/share/java/mysql-connector-java.jar

2)test = spark.read.jdbc(“jdbc:mysql://ms.itversity.com”,“retail_db.customers”,properties={“user”:“retail_user”,“password”:“itversity”})

but i am getting the following error,

return f(*a, **kw)

File “/usr/hdp/current/spark2-client/python/lib/py4j-0.10.6-src.zip/py4j/protocol.py”, line 320, in get_return_value
py4j.protocol.Py4JJavaError: An error occurred while calling o52.jdbc.
: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Could not create connection to database server.
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.Util.getInstance(Util.java:386)

Please help me in this,Thanks in advance.

Regards,
shashank

0 Likes

#2

@shashank1 - Can you please try now? If you are stilll facing the issue, let us know.

0 Likes

#3

If there is any issue, use the below command to launch pyspark shell:

pyspark --master yarn --conf spark.ui.port=12345 --jars /usr/share/java/mysql-connector-java-new.jar --driver-class-path /usr/share/java/mysql-connector-java-new.jar

0 Likes

#4

Thanks bro i am able to connect.

Regards,
S

0 Likes

closed #5
0 Likes