Registry / database / jaydebeapi

jaydebeapi

JSON →
library1.2.3pypypi✓ verified 49d ago

The JayDeBeApi module allows Python (cPython) and Jython code to connect to databases using Java JDBC drivers, providing a Python DB-API v2.0 compliant interface. It aims to offer a unified and fast interface through a flexible plug-in mechanism. The current version is 1.2.3, released in June 2020, indicating an infrequent release cadence.

database
pip install JayDeBeApi
Install & Compatibility
Where this runs
tested against v1.2.3 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
glibc
py 3.10
✕ build_error
✓ 1.7s
py 3.11
✕ build_error
✓ 1.75s
py 3.12
✕ build_error
✓ 1.65s
py 3.13
✕ build_error
✓ 1.68s
py 3.9
✕ build_error
2/6 runs
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

jaydebeapi
import jaydebeapi

This quickstart demonstrates how to establish a connection to a database using `jaydebeapi`. You need to provide the path to your JDBC driver JAR file, the fully qualified Java class name of the driver, the JDBC connection URL, and your database credentials. Remember to set the `JDBC_DRIVER_PATH`, `JDBC_DRIVER_CLASS`, `JDBC_URL`, `DB_USER`, and `DB_PASSWORD` environment variables or replace the placeholders.

import jaydebeapi import os # NOTE: Replace with your actual JDBC driver path, class name, and connection details # For example, using a placeholder for a generic JDBC driver (e.g., PostgreSQL) JDBC_DRIVER_PATH = os.environ.get('JDBC_DRIVER_PATH', '/path/to/your/jdbc_driver.jar') JDBC_DRIVER_CLASS = os.environ.get('JDBC_DRIVER_CLASS', 'org.postgresql.Driver') JDBC_URL = os.environ.get('JDBC_URL', 'jdbc:postgresql://localhost:5432/mydatabase') DB_USER = os.environ.get('DB_USER', 'user') DB_PASSWORD = os.environ.get('DB_PASSWORD', 'password') try: conn = jaydebeapi.connect( JDBC_DRIVER_CLASS, JDBC_URL, [DB_USER, DB_PASSWORD], JDBC_DRIVER_PATH ) cursor = conn.cursor() cursor.execute("SELECT 'Hello, JayDeBeApi!' AS message") result = cursor.fetchone() print(f"Connection successful: {result[0]}") cursor.close() conn.close() except Exception as e: print(f"Error connecting to database: {e}") print("Please ensure your JDBC driver path, class name, URL, and credentials are correct, and that a compatible JRE is installed and JAVA_HOME is set if necessary.")
Debug
Known issues
breakingThe `connect` method signature changed significantly in JayDeBeApi 1.0.0. Older code using positional arguments for connection properties may break.
fix
Update your `jaydebeapi.connect()` calls to use the `driver_args` parameter (as a dictionary or sequence of username/password) and `jars` parameter for driver JAR paths, as documented in versions 1.0.0 and above.
affects: < 1.0.0
gotchaIncompatibility issues with certain JPype1 versions, particularly older JayDeBeApi versions with JPype1 0.7.2+. This can lead to connection errors or crashes.
fix
Upgrade JayDeBeApi to version 1.2.1 or newer (`pip install --upgrade JayDeBeApi`) to ensure compatibility with JPype1 0.7.2+. Ensure your JPype1 version is also compatible with your Python version.
affects: < 1.2.1
gotchaJVM shared library not found errors (e.g., `No JVM shared library file (libjvm.so) found`) are common. This typically means the Java Virtual Machine cannot be located.
fix
Ensure a Java Runtime Environment (JRE) or Java Development Kit (JDK) is installed and the `JAVA_HOME` environment variable is correctly set, pointing to your Java installation directory. Also, ensure the Java architecture (32-bit vs. 64-bit) matches your Python installation.
affects: All
gotchaErrors like `java.lang.RuntimeException: Class <driver_class_name> not found` indicate that the JDBC driver JAR file is not correctly located or loaded by the JVM.
fix
Verify the `jars` parameter in `jaydebeapi.connect()` points to the correct, absolute path of your JDBC driver JAR file. Alternatively, ensure the `CLASSPATH` environment variable includes the path to your JDBC driver JARs before starting your Python script.
affects: All
gotchaMixing 32-bit Python with 64-bit Java (or vice versa) can cause `jpype` to crash, leading to unexpected program termination without clear Python exceptions.
fix
Ensure that the architecture (32-bit or 64-bit) of your Python installation matches that of your Java Runtime Environment (JRE) or Java Development Kit (JDK) installation.
affects: All
gotchaInstalling JPype1 (a dependency of JayDeBeApi) can fail if C/C++ build tools (like gcc, g++, make) are not present in the environment, particularly in minimal Docker images or environments without development packages.
fix
Ensure C/C++ build tools (e.g., `build-essential` on Debian/Ubuntu, `gcc-c++` on RHEL/CentOS) are installed in your environment before attempting to install JayDeBeApi or JPype1. For Docker, add a step like `RUN apt-get update && apt-get install -y build-essential` or `apk add build-base` in your Dockerfile.
affects: All
gotchaBuilding the 'JPype1' dependency of JayDeBeApi requires a C compiler and development headers. In minimal environments (e.g., Alpine Linux Docker images), these build tools are often not present by default, leading to compilation errors during installation.
fix
Install the necessary build tools for your operating system. For Alpine Linux (as used in this test), run `apk add build-base`. For Debian/Ubuntu, use `apt-get install build-essential`. For RHEL/CentOS, use `yum install gcc python3-devel`.
affects: All
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'jaydebeapi'
The 'jaydebeapi' package is not installed in the Python environment you are currently using.
fix
Install the package using pip: `pip install JayDeBeApi`
java.sql.SQLException: No suitable driver found
JayDeBeApi or the underlying JPype library cannot find the specified JDBC driver class or the JAR file containing it. This usually means the JAR file is not in the Java classpath or the driver class name is incorrect.
fix
Ensure the correct JDBC driver JAR file is specified in the `jars` parameter of `jaydebeapi.connect()` and that the `jclassname` matches the driver's main class. For example: `conn = jaydebeapi.connect('com.mysql.cj.jdbc.Driver', 'jdbc:mysql://localhost/test', ['user', 'password'], 'path/to/mysql-connector-java.jar')`
TypeError: Class <driver_class_name> is not found
The Java Virtual Machine (JVM) initialized by JPype could not locate the specified JDBC driver class. This often happens if the JAR file is not correctly pointed to or the class name is misspelled.
fix
Verify that the path to your JDBC driver JAR file is correct and accessible, and that the `jclassname` argument in `jaydebeapi.connect()` exactly matches the fully qualified name of the JDBC driver class. Ensure the JAR path is absolute or correctly relative to the working directory.
AttributeError: type object 'java.sql.Types' has no attribute '__javaclass__'
This error typically indicates an incompatibility between the installed versions of `jaydebeapi` and `JPype1`, especially with older `jaydebeapi` versions and newer `JPype1` versions that introduced breaking API changes.
fix
Upgrade `jaydebeapi` to version 1.2.1 or newer, which is compatible with `JPype1` versions 0.7.0 and above. Alternatively, if upgrading `jaydebeapi` is not an option, downgrade `JPype1` to a compatible version like 0.6.3 using `pip install JPype1==0.6.3 --force-reinstall`.
OSError: [WinError 126] JVM DLL not found
JPype, which `jaydebeapi` depends on, cannot find the Java Virtual Machine dynamic link library (jvm.dll on Windows or libjvm.so on Linux/macOS). This often means `JAVA_HOME` is not set correctly or Java is not installed, or there's a bitness mismatch (e.g., 32-bit Python with 64-bit Java).
fix
Ensure Java Development Kit (JDK) is installed and the `JAVA_HOME` environment variable points to the JDK installation directory. Also, make sure that the bitness of your Python interpreter (32-bit or 64-bit) matches the bitness of your Java installation.
Upgrade
Version history
1.2.3latest on PyPI
Audit
Dependencies
JPype1requiredRequired for cPython integration with Java, enabling JDBC driver usage. Specific versions (e.g., 0.6.3, 0.7.5 for Python 3) are noted for compatibility.
Java Runtime Environment (JRE)requiredJayDeBeApi relies on a functional Java environment and JDBC drivers to operate.
Agent activity
23 hits · last 30 days
node
8
seranking-bot
4
ahrefsbot
3
Meta
2
mj12bot
1
bytedance
1
Resources