use of java.sql.ParameterMetaData in project spanner-jdbc by olavloite.
the class CloudSpannerParameterMetaDataTest method testGetParameterMode.
@Test
public void testGetParameterMode() throws SQLException {
try (CloudSpannerPreparedStatement ps = createSelectStatement()) {
ParameterMetaData metadata = ps.getParameterMetaData();
assertEquals(ParameterMetaData.parameterModeIn, metadata.getParameterMode(1));
assertEquals(ParameterMetaData.parameterModeIn, metadata.getParameterMode(2));
}
try (CloudSpannerPreparedStatement ps = createInsertStatement()) {
ParameterMetaData metadata = ps.getParameterMetaData();
assertEquals(ParameterMetaData.parameterModeIn, metadata.getParameterMode(1));
assertEquals(ParameterMetaData.parameterModeIn, metadata.getParameterMode(2));
assertEquals(ParameterMetaData.parameterModeIn, metadata.getParameterMode(3));
}
}
use of java.sql.ParameterMetaData in project spanner-jdbc by olavloite.
the class CloudSpannerParameterMetaDataTest method testGetPrecision.
@Test
public void testGetPrecision() throws SQLException {
try (CloudSpannerPreparedStatement ps = createSelectStatement()) {
ParameterMetaData metadata = ps.getParameterMetaData();
assertEquals(8, metadata.getPrecision(1));
assertEquals(0, metadata.getPrecision(2));
}
try (CloudSpannerPreparedStatement ps = createInsertStatement()) {
ParameterMetaData metadata = ps.getParameterMetaData();
assertEquals(8, metadata.getPrecision(1));
assertEquals(50, metadata.getPrecision(2));
assertEquals(100, metadata.getPrecision(3));
}
}
use of java.sql.ParameterMetaData in project spanner-jdbc by olavloite.
the class CloudSpannerParameterMetaDataTest method testGetParameterCount.
@Test
public void testGetParameterCount() throws SQLException {
try (CloudSpannerPreparedStatement ps = createSelectStatement()) {
ParameterMetaData metadata = ps.getParameterMetaData();
assertEquals(2, metadata.getParameterCount());
}
try (CloudSpannerPreparedStatement ps = createInsertStatement()) {
ParameterMetaData metadata = ps.getParameterMetaData();
assertEquals(3, metadata.getParameterCount());
}
}
use of java.sql.ParameterMetaData in project spanner-jdbc by olavloite.
the class CloudSpannerParameterMetaDataTest method testGetScale.
@Test
public void testGetScale() throws SQLException {
try (CloudSpannerPreparedStatement ps = createSelectStatement()) {
ParameterMetaData metadata = ps.getParameterMetaData();
assertEquals(0, metadata.getScale(1));
assertEquals(0, metadata.getScale(2));
}
try (CloudSpannerPreparedStatement ps = createInsertStatement()) {
ParameterMetaData metadata = ps.getParameterMetaData();
assertEquals(0, metadata.getScale(1));
assertEquals(0, metadata.getScale(2));
assertEquals(0, metadata.getScale(3));
}
}
use of java.sql.ParameterMetaData in project spanner-jdbc by olavloite.
the class CloudSpannerParameterMetaDataTest method testGetParameterType.
@Test
public void testGetParameterType() throws SQLException {
try (CloudSpannerPreparedStatement ps = createSelectStatement()) {
ParameterMetaData metadata = ps.getParameterMetaData();
assertEquals(Types.BIGINT, metadata.getParameterType(1));
assertEquals(Types.OTHER, metadata.getParameterType(2));
ps.setBoolean(1, Boolean.TRUE);
assertEquals(Types.BOOLEAN, metadata.getParameterType(1));
ps.setByte(1, (byte) 1);
assertEquals(Types.TINYINT, metadata.getParameterType(1));
ps.setShort(1, (short) 1);
assertEquals(Types.SMALLINT, metadata.getParameterType(1));
ps.setInt(1, 1);
assertEquals(Types.INTEGER, metadata.getParameterType(1));
ps.setLong(1, 1l);
assertEquals(Types.BIGINT, metadata.getParameterType(1));
ps.setBigDecimal(1, BigDecimal.ONE);
assertEquals(Types.DECIMAL, metadata.getParameterType(1));
ps.setFloat(1, 1f);
assertEquals(Types.FLOAT, metadata.getParameterType(1));
ps.setDouble(1, 1d);
assertEquals(Types.DOUBLE, metadata.getParameterType(1));
ps.setDate(1, new Date(1000l));
assertEquals(Types.DATE, metadata.getParameterType(1));
ps.setTimestamp(1, new Timestamp(1000l));
assertEquals(Types.TIMESTAMP, metadata.getParameterType(1));
ps.setTime(1, new Time(1000l));
assertEquals(Types.TIME, metadata.getParameterType(1));
ps.setString(1, "FOO");
assertEquals(Types.NVARCHAR, metadata.getParameterType(1));
ps.setBytes(1, "FOO".getBytes());
assertEquals(Types.BINARY, metadata.getParameterType(1));
}
try (CloudSpannerPreparedStatement ps = createInsertStatement()) {
ParameterMetaData metadata = ps.getParameterMetaData();
assertEquals(Types.BIGINT, metadata.getParameterType(1));
assertEquals(Types.NVARCHAR, metadata.getParameterType(2));
assertEquals(Types.NVARCHAR, metadata.getParameterType(3));
}
}
Aggregations