Skip to content

Commit

Permalink
restored Connection.createBlob, createClob and createNClob
Browse files Browse the repository at this point in the history
  • Loading branch information
alexradzin committed Apr 17, 2024
1 parent 327aa57 commit fa3d19a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 46 deletions.
16 changes: 6 additions & 10 deletions src/main/java/com/firebolt/jdbc/connection/FireboltConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import lombok.NonNull;
import okhttp3.OkHttpClient;

import javax.sql.rowset.serial.SerialBlob;
import javax.sql.rowset.serial.SerialClob;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.sql.Array;
Expand Down Expand Up @@ -601,23 +599,21 @@ public CallableStatement prepareCall(String sql, int resultSetType, int resultSe
}

@Override
@NotImplemented
public Clob createClob() throws SQLException {
return new SerialClob(new char[0]);
throw new SQLFeatureNotSupportedException();
}

@Override
@NotImplemented
public Blob createBlob() throws SQLException {
return new SerialBlob(new byte[0]);
throw new SQLFeatureNotSupportedException();
}

@Override
@NotImplemented
public NClob createNClob() throws SQLException {
class SerialNClob extends SerialClob implements NClob {
public SerialNClob() throws SQLException {
super(new char[0]);
}
}
return new SerialNClob();
throw new SQLFeatureNotSupportedException();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ protected FireboltConnectionTest(String url) {

private static Stream<Arguments> unsupported() {
return Stream.of(
Arguments.of("createClob", (Executable) () -> connection.createClob()),
Arguments.of("createNClob", (Executable) () -> connection.createNClob()),
Arguments.of("createBlob", (Executable) () -> connection.createBlob()),
Arguments.of("createSQLXML", (Executable) () -> connection.createSQLXML()),
Arguments.of("createStruct", (Executable) () -> connection.createStruct("text", new Object[] {"name"})),

Expand Down Expand Up @@ -647,42 +650,6 @@ void nativeSql() throws SQLException {
}
}

@Test
void createBlob() throws SQLException {
try (FireboltConnection connection = createConnection(URL, connectionProperties)) {
String str = "hello";
Blob blob = connection.createBlob();
assertEquals(0, blob.length());
blob.setBytes(1, str.getBytes());
assertEquals(str.length(), blob.length());
assertEquals(str, new String(blob.getBytes(1, (int)blob.length())));
}
}

@Test
void createClob() throws SQLException {
try (FireboltConnection connection = createConnection(URL, connectionProperties)) {
String str = "hello";
Clob clob = connection.createClob();
assertEquals(0, clob.length());
clob.setString(1, str);
assertEquals(str.length(), clob.length());
assertEquals(str, clob.getSubString(1, str.length()));
}
}

@Test
void createNClob() throws SQLException {
try (FireboltConnection connection = createConnection(URL, connectionProperties)) {
String str = "hello";
NClob clob = connection.createNClob();
assertEquals(0, clob.length());
clob.setString(1, str);
assertEquals(str.length(), clob.length());
assertEquals(str, clob.getSubString(1, str.length()));
}
}

@Test
void unsupportedNativeSql() throws SQLException {
try (FireboltConnection connection = createConnection(URL, connectionProperties)) {
Expand Down

0 comments on commit fa3d19a

Please sign in to comment.