Skip to content

Commit 828c312

Browse files
committed
Add minimal support of Connection.*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 25b156d commit 828c312

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-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

+18
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,17 @@
1717
import org.junit.jupiter.api.Test;
1818
import org.junit.jupiter.api.function.Executable;
1919

20+
import java.sql.ClientInfoStatus;
2021
import java.sql.Connection;
2122
import java.sql.DatabaseMetaData;
2223
import java.sql.DriverManager;
2324
import java.sql.PreparedStatement;
2425
import java.sql.ResultSet;
26+
import java.sql.SQLClientInfoException;
2527
import java.sql.SQLException;
2628
import java.sql.SQLFeatureNotSupportedException;
2729
import java.sql.Statement;
30+
import java.util.Map;
2831

2932
public class JdbcConnectionIT {
3033

@@ -443,4 +446,19 @@ public void testGeneratedKeys() throws SQLException {
443446
);
444447
}
445448

449+
@Test
450+
void testSetClientInfoProperties() {
451+
String targetProperty = "ApplicationName";
452+
453+
SQLClientInfoException exception = assertThrows(
454+
SQLClientInfoException.class,
455+
() -> conn.setClientInfo(targetProperty, "TestApp")
456+
);
457+
458+
Map<String, ClientInfoStatus> failedProperties = exception.getFailedProperties();
459+
assertEquals(1, failedProperties.size());
460+
assertEquals(ClientInfoStatus.REASON_UNKNOWN_PROPERTY, failedProperties.get(targetProperty));
461+
}
462+
446463
}
464+

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

+8
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ public void tearDownTest() throws SQLException {
7575
testHelper.executeSql(CLEAN_SQL);
7676
}
7777

78+
@Test
79+
public void testGetSupportedClientInfo() throws SQLException {
80+
ResultSet rs = meta.getClientInfoProperties();
81+
assertNotNull(rs);
82+
assertFalse(rs.next());
83+
rs.close();
84+
}
85+
7886
@Test
7987
public void testGetTableTypes() throws SQLException {
8088
ResultSet rs = meta.getTableTypes();

0 commit comments

Comments
 (0)