Commit Graph

287 Commits

Author SHA1 Message Date
Pekka Enberg
a1e1e41ec2 Merge 'bindings/java: implement JDBC4 InputStream binding methods (ASCII/Binary, no-length and long overloads)' from Orange banana
## Purpose
* Implement JDBC4 stream binding methods in JDBC4PreparedStatement for
the following overloads:
  * `setAsciiStream(int, InputStream, long)`, `setAsciiStream(int,
InputStream)`
  * `setBinaryStream(int, InputStream, long)`, `setBinaryStream(int,
InputStream)`
## Changes
### In `(int, InputStream, long)` methods
* Added a shared helper method `requireLengthIsPositiveInt(long length)`
to validate stream length.
  * Validates `length` to fit SQLite’s 32-bit limit for compatibility
with SQLite/Turso engines.
* After validation passes, delegates to the `(int, InputStream, int)`
overload for actual binding logic.
### In `(int, InputeStream)` methods - no length
* Added a shared helper method `readBytes(InputStream x)`.
  * Reads the first byte before allocating the buffer to avoid
unnecessary memory allocation for empty streams.
* After reading, directly binds the data using` bindText()` (for ASCII)
or `bindBlob()` (for binary).
  * Avoids re-wrapping the stream or reallocation since the byte array
is already available.
## Related Issue
* #615

Reviewed-by: Kim Seon Woo (@seonWKim)

Closes #3937
2025-11-14 12:19:51 +02:00
Orange flavored banana
b701154e3b test(jdbc): test setAsciiStream, setBinaryStream methods (int, InputStream) 2025-11-12 14:54:40 +09:00
Orange flavored banana
28cd56d481 test(jdbc): implements setAsciiStream, setBinaryStream methods (int, InputStream) 2025-11-12 14:42:32 +09:00
Orange flavored banana
8d56c62446 test(jdbc): test setAsciiStream, setBinaryStream methods (int, InputStream, long) 2025-11-12 14:02:15 +09:00
Orange flavored banana
fe16786038 feat(jdbc): implements setAsciiStream, setBinaryStream methods (int, InputStream, long) 2025-11-12 13:51:41 +09:00
pedrocarlo
1db13889e3 Change Value::Text to use a Cow<'static, str> instead of Vec<u8> 2025-11-11 16:11:46 -03:00
Pekka Enberg
e929c252b4 Merge 'bindings/java: implement stream binding methods (int, InputStream, int) in JDBC4PreparedStatement' from Orange banana
## Purpose
* Implement `setAsciiStream(int, InputStream, int)`,
`setUnicodeStream(int, InputStream, int)`, and `setBinaryStream(int,
InputStream, int)` methods in JDBC4PreparedStatemen
## Changes
* `setAsciiStream(int, InputStream, int)`: Reads ASCII bytes, converts
to `String` using `US_ASCII` and binds with `bindText()`.
* `setUnicodeStream(int, InputStream, int)`: Reads bytes as `UTF-8`
encoded text and binds with `bindText()`.
* `setBinaryStream(int, InputStream, int)`: Reads raw bytes and binds
with `bindBlob()`.
* Added consistent error handling and validation
  * null stream - `bindNull()`
  * Negative length - throws `SQLException`
  * Empty stream  - Empty String or Empty Array
  * I/O errors - throw `SQLException`
* Ensures consistency between `setXxxStream` and `getXxxStream` methods,
so data written and read use the same encoding.
## Related Issue
* #615

Reviewed-by: Kim Seon Woo (@seonWKim)

Closes #3917
2025-11-10 11:07:08 +02:00
Pekka Enberg
c3d2ea8429 Turso 0.4.0-pre.1 2025-11-06 08:33:13 +02:00
Orange flavored banana
510b8ef59f refactor(jdbc): Added early return for length == 0 and improved read loop condition in setUnicodeStream and setAsciiStream 2025-11-06 10:13:23 +09:00
Orange flavored banana
b75e4b5a19 refactor(jdbc): prevent over-read and infinite loop in setBinaryStream 2025-11-06 09:55:36 +09:00
Orange flavored banana
0323d23b0c refactor(jdbc): Added an early return when length == 0 2025-11-06 09:33:31 +09:00
Orange flavored banana
0ef416704c refactor(jdbc): use ByteArrayOutputStream and handle empty streams as empty values instead of null 2025-11-05 14:47:47 +09:00
Orange flavored banana
efe189c21d refactor(jdbc): adjust empty stream handling and memory usage in setBinaryStream and setUnicodeStream 2025-11-05 11:39:48 +09:00
Orange flavored banana
52f8c1a33e feat(jdbc): test setUnicodeStream method in JDBC4PreparedStatementTest 2025-11-04 17:48:31 +09:00
Orange flavored banana
100662d134 feat(jdbc): implement setUnicodeStream method in JDBC4PreparedStatement 2025-11-04 17:45:36 +09:00
Orange flavored banana
8dd666e131 feat(jdbc): test setBinaryStream method in JDBC4PreparedStatementTest 2025-11-04 17:32:33 +09:00
Orange flavored banana
679841fc9d feat(jdbc): implement setBinaryStream method in JDBC4PreparedStatement 2025-11-04 17:27:34 +09:00
Orange flavored banana
11186312bd feat(jdbc): test setAsciiStream method in JDBC4PreparedStatementTest 2025-11-04 17:14:52 +09:00
Orange flavored banana
8f35a0c4c1 feat(jdbc): implement setAsciiStream method in JDBC4PreparedStatement 2025-11-04 16:48:28 +09:00
Pekka Enberg
cdd9ec3438 Merge 'bindings/java: Implement setObject(int, Object) in JDBC4PreparedStatement' from Orange banana
## Purpose
* Implement `setObject(int, Object)` to support binding of common Java
types to SQL parameters in JDBC4.
* This implementation currently covers only standard JDBC4 supported
types. LOB and stream bindings are not yet implemented.
## Changes
* Implemented JDBC4PreparedStatement#setObject(int, Object) handling for
  * `String`, `Integer`, `Long`, `Boolean`, `Double`, `Float`, `Byte`,
`Short`
  * `byte[]`, `Date`, `Time`, `Timestamp`, `BigDecimal`
* Added validation for unsupported types (`Blob`, `Clob`, `InputStream`,
`Reader`)
* Added corresponding unit test `testSetObjectCoversAllSupportedTypes`
to verify correctness
## Note
* Additional work (e.g., LOB/Stream handling) will be addressed
separately once driver support is available.
## Related Issue
#615

Reviewed-by: Kim Seon Woo (@seonWKim)

Closes #3864
2025-10-31 17:00:31 +02:00
Orange flavored banana
5fef79d9f6 feat(jdbc): remove unnecessary java.sql prefixes in setObject 2025-10-31 10:38:30 +09:00
Orange flavored banana
4cd007f2eb Test(jdbc): Add coverage for setObject(int, Object) 2025-10-30 15:35:31 +09:00
Orange flavored banana
53ab453015 Feat(jdbc): Implement setObject(int, Object) in JDBC4PreparedStatement 2025-10-30 09:54:42 +09:00
kimminseok
2b456ec7e4 chore: apply spotless formatting 2025-10-27 00:31:49 +09:00
김민석
24181ad307 Merge branch 'main' into feature/result-set-was-null 2025-10-26 23:02:36 +09:00
kimminseok
17f1a070ed Add comprehensive tests for ResultSet getter methods 2025-10-26 22:37:47 +09:00
kimminseok
71f53b5850 Add wasNull tracking to getObject methods 2025-10-26 22:36:38 +09:00
kimminseok
27233a947f Add consistent wasNull handling for stream getter methods 2025-10-26 22:34:43 +09:00
kimminseok
7ee339a754 Extract timezone offset calculation to helper method 2025-10-26 22:09:47 +09:00
kimminseok
791e19892d Refactor columnLabel getters to use delegation pattern 2025-10-26 21:45:54 +09:00
kimminseok
5f10e647e3 Fix wasNull not being set in getter methods 2025-10-26 21:31:11 +09:00
Pekka Enberg
12783ef01e Merge 'bindings/java: Add support for publishing to Maven Central' from Kim Seon Woo
## Purpose
- Deploy `tech.turso:turso:<version>` to maven central so that users can
easily use java bindings
  - For example :
https://repo1.maven.org/maven2/io/github/seonwkim/turso/0.0.1/
## Requirements
- [x] Add the following github secrets.
  - [x] MAVEN_CENTRAL_USERNAME
  - [x] MAVEN_CENTRAL_PASSWORD
  - [x] GPG_PRIVATE_KEY
  - [x] GPG_PASSPHRASE
- [ ] Namespace `tech.turso` must be registered at maven central
- [ ] GPG key registration to key servers
- Notes
  - Retrieve MAVEN_CENTRAL_USERNAME and MAVEN_CENTRAL_PASSWORD from
[maven central](https://central.sonatype.com/usertoken)
  - GPG keys should be registered. You should distribute your keys to
designated(maven central supported) servers
    -  Refer to [GPG key related docs](https://central.sonatype.org/publ
ish/requirements/gpg/#distributing-your-public-key)
    - Btw, I used `keyserver.ubuntu.com` key server while testing
### [Maven Central Username &
Password](https://central.sonatype.com/usertoken)
<img width="2878" height="1338" alt="image"
src="https://github.com/user-
attachments/assets/03e6f967-a7f6-46b8-aef5-d15772bd9eea" />
### [Maven Central
Namespace](https://central.sonatype.com/publishing/namespaces)
<img width="1424" height="456" alt="image" src="https://github.com/user-
attachments/assets/8c0f4f17-bf5a-4c6a-bc47-748d86cd1f1a" />
## Future Works
- Currently, we depend on gradle.properties to determine the version of
our dependency and it's cumbersome to always change the version
manually. Let's find a better solution.

Closes #3624
2025-10-10 13:12:01 +03:00
kimminseok
76320e82db lint issues with spotless 2025-10-09 11:19:29 +09:00
kimminseok
f9e95697c8 handle empty string in findColumn() method 2025-10-09 10:46:27 +09:00
kimminseok
76b57e5d0c correctly detect empty ResultSet in next() 2025-10-09 10:29:46 +09:00
Kim Seon Woo
722c906ca6 Change variable names 2025-10-08 15:43:27 +09:00
kimminseok
104c2ffc5e Fix isBeforeFirst to return false for empty ResultSet 2025-10-08 00:40:15 +09:00
kimminseok
043a9fc7b8 Change to verify full exception messages in findColumn tests 2025-10-08 00:25:28 +09:00
Kim Seon Woo
d90d0f3f9f Separate publish.gradle.kts from build.gradle.kts 2025-10-07 23:52:12 +09:00
Kim Seon Woo
e9ccdf15d8 Apply lint 2025-10-07 23:52:03 +09:00
kimminseok
64fd282eb0 Fix NullAway warnings in JDBC4ResultSet 2025-10-07 23:50:48 +09:00
Kim Seon Woo
8af9a53818 Update build.gradle.kts for publishing 2025-10-07 23:37:53 +09:00
Kim Seon Woo
fe7027e8ee Fix Makefile libs command 2025-10-07 23:33:13 +09:00
Kim Seon Woo
76af79c4fa Add javadoc on classes and public methods for publishing to maven central 2025-10-07 23:33:02 +09:00
kimminseok
253d54c15a Fix spotless lint errors 2025-10-07 23:18:35 +09:00
kimminseok
85f2755837 feat(java): implement getTimestamp() in JDBC4ResultSet 2025-10-07 14:30:03 +09:00
kimminseok
ffd43b4b77 feat(java): implement getTime() in JDBC4ResultSet 2025-10-07 14:25:46 +09:00
kimminseok
6adc272d75 feat(java): implement getDate() in JDBC4ResultSet 2025-10-07 14:22:13 +09:00
kimminseok
fb370c63a6 feat(java): implement getRow() in JDBC4ResultSet 2025-10-07 14:18:34 +09:00
kimminseok
fd61ddbd21 feat(java): implement isBeforeFirst(), isAfterLast() in JDBC4ResultSet 2025-10-07 14:15:10 +09:00