Fix: wrap getConnection() in try/except for DB-API error handling (legacy #218)#70
Open
HenryNebula wants to merge 1 commit intodevfrom
Open
Fix: wrap getConnection() in try/except for DB-API error handling (legacy #218)#70HenryNebula wants to merge 1 commit intodevfrom
HenryNebula wants to merge 1 commit intodevfrom
Conversation
HenryNebula
added a commit
that referenced
this pull request
Apr 26, 2026
…gacy #70) The fallback path's _to_java() was dropping microseconds when converting Python datetime to java.sql.Timestamp (%S instead of %S.%f), and time.isoformat() could produce fractional seconds that java.sql.Time rejects. Also adds regression tests for datetime/date/time parameter binding in both mock and integration test suites. Closes #88 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
cec4bf3 to
053c98f
Compare
…PI error handling The original issue (legacy #218) reported a JVM-level crash during DB2 connection that could not be caught by Python. While JVM crashes are outside our control, the connection code was also missing proper exception handling for normal connection failures (bad credentials, network errors, etc.). Java SQLExceptions from getConnection() now map to DB-API 2.0 DatabaseError instead of propagating as raw Java exceptions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
HenryNebula
added a commit
that referenced
this pull request
Apr 28, 2026
…gacy #70) The fallback path's _to_java() was dropping microseconds when converting Python datetime to java.sql.Timestamp (%S instead of %S.%f), and time.isoformat() could produce fractional seconds that java.sql.Time rejects. Also adds regression tests for datetime/date/time parameter binding in both mock and integration test suites. Closes #88 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
053c98f to
d7fe5d6
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #69: Connection failures (SQLException from
DriverManager.getConnection()) now properly raise DB-API 2.0DatabaseErrorinstead of propagating as raw Java exceptions.The original issue reported a JVM-level crash during DB2 connection. While JVM crashes are outside our control, the connection code was missing proper exception handling for normal connection failures (bad credentials, network errors, etc.).
Changes
DriverManager.getConnection()in try/except with_handle_sql_exception()to map Java SQLExceptions to DB-API 2.0DatabaseErrorfail-connectURL pattern to MockDriver for simulating connection failuresDatabaseErrorDatabaseErrorTest plan
CLASSPATH="test/jars/*:test/mock-jars/*" uv run python -m unittest test.test_mockCLASSPATH="test/jars/*" uv run python -m unittest test.test_integration.HsqldbTestCloses #69
Generated with Claude Code