Open stephenharper82 opened 2 years ago
Hi , Have the exact same issue here , all is working but got a nasty error : indows fatal exception: access violation
Current thread 0x0000a1f4 (most recent call first): File "C:\Users\hkfir\PycharmProjects\KfirDemoAPIAuto.venv\Lib\site-packages\jpype_core.py", line 247 in startJVM
I am using python 3.12. These are the relevant dependencies:
JayDeBeApi 1.2.3 JPype 1.5.0
This is the code that interacts with the db: HOST = "localhost" PORT = 9001 DATABASE_NAME = "parabank" JDBC_URL = f"jdbc:hsqldb:hsql://{HOST}:{PORT}/{DATABASE_NAME}" JDBC_DRIVER = "org.hsqldb.jdbc.JDBCDriver" JDBC_DRIVER_PATH = "libs/hsqldb.jar" # Path to the JAR inside the 'libs' folder USERNAME = "SA" # Default user for HSQLDB PASSWORD = "" # Default password for HSQLDB (empty by default)
@classmethod
def get_customer_ids_from_db(cls, query):
"""
Queries the HSQLDB database and returns customer IDs that match the specified query.
Args:
query (str): The SQL query to execute on the database.
Returns:
list: A list of customer IDs retrieved from the database.
"""
try:
conn = jaydebeapi.connect(cls.JDBC_DRIVER, cls.JDBC_URL, [cls.USERNAME, cls.PASSWORD],
cls.JDBC_DRIVER_PATH)
cursor = conn.cursor()
# Execute the query
cursor.execute(query)
# Fetch all results
customer_ids = cursor.fetchall()
# Close the cursor and connection
cursor.close()
conn.close()
log = cls.get_logger()
log.info(f"this are the customer ids found {customer_ids}")
# Return the customer IDs (list of tuples)
return customer_ids
except Exception as e:
log = cls.get_logger()
log.error(f"Error while executing the query: {query}. Error: {e}")
raise
Thanks , Kfir
Hi,
I get this error when I try to connect to a h2 db. It doesn't appear to halt execution though and I can see the connection made, tables created, data inserted and results queried, but the stacktrace isn't very nice.
Unfortunately this is happening in my work and I can't really share full details. I'm doing this from my home PC retrospectilvey. Hopefully this is enough detail, but I can supply anything else if you need it.
I am using python 3.7. These are the relevant dependencies:
JayDeBeApi 1.2.3 JPype 1.3.0
con = jaydebeapi.connect("org.h2.Driver", "jdbc:h2:mem:.", ["sa", ""], "resources/h2-1.4.197.jar",)
I can see it is happening on jpye/_core.py line 227 in startJVM where it calls _jpype.startuip(jvmpath...
It does make the connection, and is able to create table, insert and populate , but doesn't look very clean.
Any help is much appreciated.
Thanks, Stephen