2015-10-07 118 views
1

我正嘗試使用jaydebeapi包連接到teradata數據庫。jaydebeapi teradata連接

conn = jaydebeapi.connect('com.teradata.jdbc.TeraDriver', 
          ['jdbc:teradata://ip/TMODE=ANSI,CHARSET=utf8', 'username', 'password'], 
          ['/teradata/tdgssconfig.jar', 
          '/terajdbc4.jar']) 

錯誤而執行:

TERAJDBC4 ERROR [main] [email protected] Connection to <ip_address> Wed Oct 07 13:47:29 IST 2015 socket orig=<ip_address> cid=22f79598 sess=0 java.net.SocketTimeoutException: connect timed out at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:579) at com.teradata.jdbc.jdbc_4.io.TDNetworkIOIF$ConnectThread.run(TDNetworkIOIF.java:1216) 
Traceback (most recent call last): 
    File "test_teradata.py", line 32, in <module> 
    teradataconn() 
    File "test_teradata.py", line 26, in teradataconn 
    '/home/abhishek/git/dblore/code/lib/teradata/terajdbc4.jar']) 
    File "/usr/local/lib/python2.7/dist-packages/jaydebeapi/__init__.py", line 359, in connect 
    jconn = _jdbc_connect(jclassname, jars, libs, *driver_args) 
    File "/usr/local/lib/python2.7/dist-packages/jaydebeapi/__init__.py", line 183, in _jdbc_connect_jpype 
    return jpype.java.sql.DriverManager.getConnection(*driver_args) 
jpype._jexception.SQLExceptionPyRaisable: java.sql.SQLException: [Teradata JDBC Driver] [TeraJDBC 15.00.00.20] [Error 1277] [SQLState 08S01] Login timeout for Connection to <ip_address> Wed Oct 07 13:47:29 IST 2015 socket orig=<ip_address> cid=22f79598 sess=0 java.net.SocketTimeoutException: connect timed out at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:339) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:200) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:182) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:579) at com.teradata.jdbc.jdbc_4.io.TDNetworkIOIF$ConnectThread.run(TDNetworkIOIF.java:1216) 
+0

「SocketTimeoutException:連接超時」沒有ip服務器,或它沒有及時響應(例如,因爲防火牆或其他網絡問題) –

+0

我能夠通過Java連接到數據庫使用相同的JDBC驅動程序和參數。 – Abhi

回答

1

我用下面的代碼連接到Teradata的數據庫,它的工作原理與幾個服務器和數據庫。

import jaydebeapi 
server=192.168.3.4 
database=dbc 
user=dbc 
password=dbc 

# from TD JDBC readme.txt 
jclassname='com.teradata.jdbc.TeraDriver' 
# from TD Studio jdbc:<subprotocol>://<server>:<port>/<database> 
url='jdbc:teradata://'+server+'/'+database 
# driver args contains the arguments passed to java: DriverManager.getConnections(...) 
driver_args=[url,user,password] 
# my jars are in CLASSPATH environment variable, if not then put the paths to them into a list, e.g.: jars=[r'C:\Program Files\Teradata\TeraJDBC\terajdbc4.jar;C:\Program Files\Teradata\TeraJDBC\tdgssconfig.jar'] 
jars=None 

jaydebeapi.connect(jclassname,driver_args,jars) 

與您的代碼相比較,我只看到IP(更換你的真實IP地址,我猜)在您的網址,你是否也已添加的數據庫名稱那裏的路徑?否則,問題可能在那裏。