baztian / jaydebeapi

JayDeBeApi module allows you to connect from Python code to databases using Java JDBC. It provides a Python DB-API v2.0 to that database.
GNU Lesser General Public License v3.0
365 stars 148 forks source link

Unable to connect to database #93

Open pankulmittal opened 5 years ago

pankulmittal commented 5 years ago

import jpype import jaydebeapi classpath = "/opt/apache-drill-1.14.0/jars/jdbc-driver/drill-jdbc-all-1.14.0.jar" jpype.startJVM(jpype.getDefaultJVMPath(), "-Djava.class.path=%s" % classpath) HOST_IP = "127.0.0.1" HOST_PORT = "31000" conn = jaydebeapi.connect("org.apache.drill.jdbc.Driver", f"jdbc:drill:drillbit={HOST_IP}:{HOST_PORT}", ["username", "password"], classpath,)

Traceback (most recent call last): File "", line 1, in File "build/bdist.linux-x86_64/egg/jaydebeapi/init.py", line 63, in connect File "/usr/local/lib/python2.7/dist-packages/py4j-0.10.8.1-py2.7.egg/py4j/java_gateway.py", line 2113, in launch_gateway enable_auth=enable_auth) File "/usr/local/lib/python2.7/dist-packages/py4j-0.10.8.1-py2.7.egg/py4j/java_gateway.py", line 327, in launch_gateway _port = int(proc.stdout.readline()) ValueError: invalid literal for int() with base 10: ''

Please help me with this I am not able to make a connection with the database server.

ebb-earl-co commented 4 years ago

@pankulmittal Because the error is to do with int, I think that it is choking on your HOST_PORT variable: ports are integers, not strings. Try to change it from "31000" to 31000 and see what that does for you.