Search in sources :

Example 61 with ParameterMetaData

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));
    }
}
Also used : ParameterMetaData(java.sql.ParameterMetaData) Test(org.junit.Test) UnitTest(nl.topicus.jdbc.test.category.UnitTest)

Example 62 with ParameterMetaData

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));
    }
}
Also used : ParameterMetaData(java.sql.ParameterMetaData) Test(org.junit.Test) UnitTest(nl.topicus.jdbc.test.category.UnitTest)

Example 63 with ParameterMetaData

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());
    }
}
Also used : ParameterMetaData(java.sql.ParameterMetaData) Test(org.junit.Test) UnitTest(nl.topicus.jdbc.test.category.UnitTest)

Example 64 with ParameterMetaData

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));
    }
}
Also used : ParameterMetaData(java.sql.ParameterMetaData) Test(org.junit.Test) UnitTest(nl.topicus.jdbc.test.category.UnitTest)

Example 65 with ParameterMetaData

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));
    }
}
Also used : Time(java.sql.Time) Timestamp(java.sql.Timestamp) ParameterMetaData(java.sql.ParameterMetaData) Date(java.sql.Date) Test(org.junit.Test) UnitTest(nl.topicus.jdbc.test.category.UnitTest)

Aggregations

ParameterMetaData (java.sql.ParameterMetaData)136 PreparedStatement (java.sql.PreparedStatement)82 Test (org.junit.Test)55 Connection (java.sql.Connection)45 SQLException (java.sql.SQLException)35 BaseConnectionlessQueryTest (org.apache.phoenix.query.BaseConnectionlessQueryTest)31 ResultSet (java.sql.ResultSet)22 Statement (java.sql.Statement)20 ResultSetMetaData (java.sql.ResultSetMetaData)18 SQLServerParameterMetaData (com.microsoft.sqlserver.jdbc.SQLServerParameterMetaData)15 BigDecimal (java.math.BigDecimal)12 CallableStatement (java.sql.CallableStatement)12 Test (org.junit.jupiter.api.Test)12 AbstractTest (com.microsoft.sqlserver.testframework.AbstractTest)11 UnitTest (nl.topicus.jdbc.test.category.UnitTest)9 StringContains.containsString (org.hamcrest.core.StringContains.containsString)9 Date (java.sql.Date)7 DisplayName (org.junit.jupiter.api.DisplayName)7 ArrayList (java.util.ArrayList)5 List (java.util.List)5