Package dev.frostlake.jdbc
Class JdbcMarshaling
java.lang.Object
dev.frostlake.jdbc.JdbcMarshaling
Shared marshaling between the engine's stored values / type names and JDBC types, used by both the
HTTP-backed (
Database*) and in-process (Direct*) ResultSet and metadata implementations so
the conversion lives in ONE place. The engine stores temporal values as java.time types
(see DateTimeType) and BINARY as byte[] (see BinaryType); over the HTTP/JSON wire a
LocalDateTime arrives as an ISO string and a byte[] as Base64, so the converters accept
both the live objects and their string renderings.-
Method Summary
Modifier and TypeMethodDescriptionstatic StringcolumnClassName(int sqlType) The class nameResultSet.getObjectyields for aTypesconstant.static intcountPlaceholders(String sql) Count the?placeholders insql, skipping any inside single-quoted string literals.static StringformatLiteral(Object value) Render a parameter value as a SQL literal.The named parameters (:name) ofsql, uppercased, in order of appearance.static StringRewrite named parameters (:name) in a callable-statement SQL to positional?placeholders.static byte[]Read a byte stream fully into a byte[] (for PreparedStatement binary/blob parameters).static StringRead a byte stream fully into a UTF-8 String (for PreparedStatement ASCII/unicode-stream parameters).static StringreadToString(Reader reader) Read a character stream fully into a String (for PreparedStatement character/clob parameters).static StringsubstitutePlaceholders(String sql, List<Object> values) Bind an ordered list of values to the?placeholders insql(1-based, positional) — e.g.static StringsubstitutePlaceholders(String sql, Map<Integer, Object> params) Substitute?placeholders insqlwith the formatted parameters (1-based keys), skipping any?that sits inside a single-quoted string literal so a literal like'a?b'doesn't consume a placeholder slot.static byte[]static Datestatic intMap an engineDataTypeto aTypesconstant, using its PARAMETERS where they decide the answer.static intMap an engineDataTypename to aTypesconstant.static intAs above, for a caller that has the type's NAME and SCALE rather than the type itself.static Timestatic Timestamp
-
Method Details
-
toSqlType
Map an engineDataTypeto aTypesconstant, using its PARAMETERS where they decide the answer. Every integer alias is NUMBER(38,0) in the catalog, as on a real account, so the name alone can no longer tell an integer column from a decimal one — the SCALE does, and live agrees: an INT column reportsTypes.BIGINTover JDBC and a NUMBER(10,2) reportsTypes.DECIMAL. It is the same rule this driver's metadata queries already apply to INFORMATION_SCHEMA rows. -
toSqlType
As above, for a caller that has the type's NAME and SCALE rather than the type itself. -
toSqlType
Map an engineDataTypename to aTypesconstant. -
columnClassName
The class nameResultSet.getObjectyields for aTypesconstant. Integral types map toLongbecause the engine stores INTEGER/BIGINT/etc. asLong(notInteger). -
toTimestamp
-
toDate
-
toTime
-
toBytes
-
substitutePlaceholders
Bind an ordered list of values to the?placeholders insql(1-based, positional) — e.g. Snowflake'sEXECUTE IMMEDIATE '… ? … ?' USING (v1, v2). -
substitutePlaceholders
Substitute?placeholders insqlwith the formatted parameters (1-based keys), skipping any?that sits inside a single-quoted string literal so a literal like'a?b'doesn't consume a placeholder slot. (PreparedStatement params are inlined client-side; there is no server-side binding.) -
namedParametersToPositional
Rewrite named parameters (:name) in a callable-statement SQL to positional?placeholders. Driven by the lexer, so a:that sits inside a string literal (part of a STRING_LITERAL token) — or::/:=(their own tokens) — is never a parameter. -
namedParameterOrder
The named parameters (:name) ofsql, uppercased, in order of appearance. -
formatLiteral
Render a parameter value as a SQL literal. Strings escape BOTH backslash and single-quote — the lexer honors\-escapes (see the STRING_LITERAL grammar rule), so doubling only the quote would let a trailing backslash break out of the literal. Temporal values are emitted in ISO form the engine parses. -
countPlaceholders
Count the?placeholders insql, skipping any inside single-quoted string literals. -
readToString
Read a character stream fully into a String (for PreparedStatement character/clob parameters).- Throws:
SQLException
-
readToString
Read a byte stream fully into a UTF-8 String (for PreparedStatement ASCII/unicode-stream parameters).- Throws:
SQLException
-
readToBytes
Read a byte stream fully into a byte[] (for PreparedStatement binary/blob parameters).- Throws:
SQLException
-