from pyspark.sql import SparkSession
spark = SparkSession.builder.getOrCreate()
def load_data(driver, jdbc_url, sql, user, password):
return spark.read \
.format('jdbc') \
.option('driver', driver) \
.option('url', jdbc_url) \
.option('dbtable', '({sql}) as src'.format(sql=sql)) \
.option('user', user) \
.option('password', password) \
.load()
driver = 'com.teradata.jdbc.TeraDriver'
sql = "select * from hr.employees"
url = "jdbc:teradata://<IPADDRESS>/Database=dbc,LOGMECH=TD2"
user = "dbc"
password = "dbc"
df_td = load_data(driver,url,sql,user,password)
df_td.show(10)
Am getting the following error:
java.sql.SQLException: [Teradata JDBC Driver] [TeraJDBC 17.20.00.08] [Error 1277] [SQLState 08S01] Login timeout for Connection to XXXXX Thu Aug 18 08:18:31 UTC 2022 socket orig=XXXXX cid=2ab4c070 sess=0 java.net.SocketTimeoutException: connect timed out at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:607) at com.teradata.jdbc.jdbc_4.io.TDNetworkIOIF$ConnectThread.run(TDNetworkIOIF.java:1569)