Skip to content

Fix: convert Python datetime objects to java.sql.Timestamp for parameter binding (legacy #70) #88

@HenryNebula

Description

@HenryNebula

Description

When calling cursor.execute() with Python datetime.datetime or datetime.date objects as parameters, JPype raises No matching overloads found for setObject because it cannot automatically convert Python datetime types to java.sql.Timestamp or java.sql.Date.

This affects stored procedure calls and parameterized queries that pass datetime values.

Steps to Reproduce

import jaydebeapi
conn = jaydebeapi.connect(driver_class, jdbc_url, [user, pass], jars)
cursor = conn.cursor()
cursor.execute("{call sp_UpsertTS(?,?,?,?,?,?)}", (id, datetime_obj, end_time, userid, pairid, username))
# RuntimeError: No matching overloads found for setObject

Expected Behavior

Python datetime.datetime should be automatically converted to java.sql.Timestamp, and datetime.date to java.sql.Date before being passed to PreparedStatement.setObject().

Legacy Reference

baztian/jaydebeapi#70

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions