Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ParameterMetaData.getParameterType(int) throws "No parameter has been set yet" error #1218

Closed
jehugaleahsa opened this issue Dec 12, 2024 · 2 comments

Comments

@jehugaleahsa
Copy link
Contributor

Describe the bug
After creating a PreparedStatement for SELECT, INSERT, etc., you were able to query the parameter type in release 3.41.2.1. Now in 3.46.1.3 this is no longer possible. It's very useful to detect the parameter type in SQLite (even if it can be dynamic within the actual table rows) in order to execute generic import processes.

To Reproduce
Create a table in a SQLite file. The columns will have types, as defined in the CREATE command.

Then create PreparedStatement for an INSERT statement and call:

ParameterMetaData parameterMetadata = statement.getParameterMetaData();
parameterMetadata.getParameterType(1); // This throws now

Expected behavior
In the past, this method would not throw. It would return a integer value (see java.sql.Types) corresponding to the column type provided in the CREATE statement.

Environment (please complete the following information):

  • OS: Windows 11
  • CPU architecture: x86_64
  • sqlite-jdbc version: 3.46.1.3

Additional context
I can technically get away with inspecting the type of value I am INSERT-ing and call the correct statement.set* method, because SQLite doesn't care. However, the code I am working with is meant to be generic and work with any JDBC implementation, so making a change would also break code working with Postgres, etc.

Please feel free to push back if you don't think this is expected JDBC behavior, and I will research other ways of determining the parameter type.

@gotson
Copy link
Collaborator

gotson commented Dec 18, 2024

It would return a integer value (see java.sql.Types) corresponding to the column type provided in the CREATE statement.

I don't think this is true. It would always return VARCHAR before. https://github.com/xerial/sqlite-jdbc/releases/tag/3.41.2.2 brought #882 which looks at the parameter type already set.

There is a whole discussion in #928 about what the correct behaviour should be.

@gotson gotson added question Further information is requested and removed triage labels Dec 18, 2024
@jehugaleahsa
Copy link
Contributor Author

Thank you. Feel free to mark this as a duplicate then.

@gotson gotson added duplicate and removed question Further information is requested labels Dec 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants