Skip to content

Commit 8fba046

Browse files
committed
Add minimal support of Statement.*ClientInfo()
At present, the driver doesn't support any properties and must retrieve empty data instead of raising an error with an exception for Statement.setClientInfo which will throw ClientInfoException for any attempts to set a property. Closes: #74
1 parent fb0b37d commit 8fba046

File tree

3 files changed

+27
-2
lines changed

3 files changed

+27
-2
lines changed

src/main/java/org/tarantool/jdbc/SQLConnection.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -479,13 +479,13 @@ private void throwUnknownClientProperties(Collection<Object> properties) throws
479479
@Override
480480
public String getClientInfo(String name) throws SQLException {
481481
checkNotClosed();
482-
throw new SQLFeatureNotSupportedException();
482+
return null;
483483
}
484484

485485
@Override
486486
public Properties getClientInfo() throws SQLException {
487487
checkNotClosed();
488-
throw new SQLFeatureNotSupportedException();
488+
return new Properties();
489489
}
490490

491491
@Override

src/test/java/org/tarantool/jdbc/JdbcConnectionIT.java

+16
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.junit.jupiter.api.Test;
1313
import org.junit.jupiter.api.function.Executable;
1414

15+
import java.sql.ClientInfoStatus;
1516
import java.sql.Connection;
1617
import java.sql.DatabaseMetaData;
1718
import java.sql.PreparedStatement;
@@ -21,6 +22,7 @@
2122
import java.sql.SQLFeatureNotSupportedException;
2223
import java.sql.Statement;
2324
import java.util.Collections;
25+
import java.util.Map;
2426
import java.util.Properties;
2527

2628
public class JdbcConnectionIT extends AbstractJdbcIT {
@@ -550,5 +552,19 @@ public void testUnavailableMethodsAfterClose() throws SQLException {
550552
assertSqlExceptionHasStatus(sqlException, SQLStates.CONNECTION_DOES_NOT_EXIST);
551553
}
552554

555+
@Test
556+
void testSetClientInfoProperties() {
557+
String targetProperty = "ApplicationName";
558+
559+
SQLClientInfoException exception = assertThrows(
560+
SQLClientInfoException.class,
561+
() -> conn.setClientInfo(targetProperty, "TestApp")
562+
);
563+
564+
Map<String, ClientInfoStatus> failedProperties = exception.getFailedProperties();
565+
assertEquals(1, failedProperties.size());
566+
assertEquals(ClientInfoStatus.REASON_UNKNOWN_PROPERTY, failedProperties.get(targetProperty));
567+
}
568+
553569
}
554570

src/test/java/org/tarantool/jdbc/JdbcDatabaseMetaDataIT.java

+9
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,15 @@ public void setUp() throws SQLException {
2828
meta = conn.getMetaData();
2929
}
3030

31+
@Test
32+
public void testGetSupportedClientInfo() throws SQLException {
33+
ResultSet rs = meta.getClientInfoProperties();
34+
assertNotNull(rs);
35+
assertFalse(rs.next());
36+
rs.close();
37+
}
38+
39+
3140
@Test
3241
public void testGetTableTypes() throws SQLException {
3342
ResultSet rs = meta.getTableTypes();

0 commit comments

Comments
 (0)