Search in sources :

Example 1 with SqlDate

use of com.microsoft.sqlserver.testframework.sqlType.SqlDate in project mssql-jdbc by Microsoft.

the class Utils method types.

/**
 * @return
 */
public static ArrayList<SqlType> types() {
    if (null == types) {
        types = new ArrayList<>();
        types.add(new SqlInt());
        types.add(new SqlSmallInt());
        types.add(new SqlTinyInt());
        types.add(new SqlBit());
        types.add(new SqlDateTime());
        types.add(new SqlSmallDateTime());
        types.add(new SqlDecimal());
        types.add(new SqlNumeric());
        types.add(new SqlReal());
        types.add(new SqlFloat());
        types.add(new SqlMoney());
        types.add(new SqlSmallMoney());
        types.add(new SqlVarChar());
        types.add(new SqlChar());
        // types.add(new SqlText());
        types.add(new SqlBinary());
        types.add(new SqlVarBinary());
        // types.add(new SqlImage());
        // types.add(new SqlTimestamp());
        types.add(new SqlNVarChar());
        types.add(new SqlNChar());
        // types.add(new SqlNText());
        // types.add(new SqlGuid());
        types.add(new SqlBigInt());
        // types.add(new SqlVariant(this));
        // 9.0 types
        types.add(new SqlVarCharMax());
        types.add(new SqlNVarCharMax());
        types.add(new SqlVarBinaryMax());
        // types.add(new SqlXml());
        // 10.0 types
        types.add(new SqlDate());
        types.add(new SqlDateTime2());
        types.add(new SqlTime());
        types.add(new SqlDateTimeOffset());
    }
    return types;
}
Also used : SqlTinyInt(com.microsoft.sqlserver.testframework.sqlType.SqlTinyInt) SqlSmallMoney(com.microsoft.sqlserver.testframework.sqlType.SqlSmallMoney) SqlNVarCharMax(com.microsoft.sqlserver.testframework.sqlType.SqlNVarCharMax) SqlVarBinaryMax(com.microsoft.sqlserver.testframework.sqlType.SqlVarBinaryMax) SqlVarChar(com.microsoft.sqlserver.testframework.sqlType.SqlVarChar) SqlTime(com.microsoft.sqlserver.testframework.sqlType.SqlTime) SqlDateTime(com.microsoft.sqlserver.testframework.sqlType.SqlDateTime) SqlVarBinary(com.microsoft.sqlserver.testframework.sqlType.SqlVarBinary) SqlNChar(com.microsoft.sqlserver.testframework.sqlType.SqlNChar) SqlBigInt(com.microsoft.sqlserver.testframework.sqlType.SqlBigInt) SqlVarCharMax(com.microsoft.sqlserver.testframework.sqlType.SqlVarCharMax) SqlNVarChar(com.microsoft.sqlserver.testframework.sqlType.SqlNVarChar) SqlSmallInt(com.microsoft.sqlserver.testframework.sqlType.SqlSmallInt) SqlDateTimeOffset(com.microsoft.sqlserver.testframework.sqlType.SqlDateTimeOffset) SqlBinary(com.microsoft.sqlserver.testframework.sqlType.SqlBinary) SqlDecimal(com.microsoft.sqlserver.testframework.sqlType.SqlDecimal) SqlMoney(com.microsoft.sqlserver.testframework.sqlType.SqlMoney) SqlInt(com.microsoft.sqlserver.testframework.sqlType.SqlInt) SqlDateTime2(com.microsoft.sqlserver.testframework.sqlType.SqlDateTime2) SqlChar(com.microsoft.sqlserver.testframework.sqlType.SqlChar) SqlBit(com.microsoft.sqlserver.testframework.sqlType.SqlBit) SqlFloat(com.microsoft.sqlserver.testframework.sqlType.SqlFloat) SqlDate(com.microsoft.sqlserver.testframework.sqlType.SqlDate) SqlSmallDateTime(com.microsoft.sqlserver.testframework.sqlType.SqlSmallDateTime) SqlReal(com.microsoft.sqlserver.testframework.sqlType.SqlReal) SqlNumeric(com.microsoft.sqlserver.testframework.sqlType.SqlNumeric)

Example 2 with SqlDate

use of com.microsoft.sqlserver.testframework.sqlType.SqlDate in project mssql-jdbc by Microsoft.

the class TVPWithSqlVariantTest method testDate.

/**
 * Test with date value
 *
 * @throws SQLException
 * @throws SQLTimeoutException
 */
@Test
public void testDate() throws SQLException {
    SqlDate sqlDate = new SqlDate();
    Date date = (Date) sqlDate.createdata();
    tvp = new SQLServerDataTable();
    tvp.addColumnMetadata("c1", microsoft.sql.Types.SQL_VARIANT);
    tvp.addRow(date);
    pstmt = (SQLServerPreparedStatement) connection.prepareStatement("INSERT INTO " + destTable + " select * from ? ;");
    pstmt.setStructured(1, tvpName, tvp);
    pstmt.execute();
    if (null != pstmt) {
        pstmt.close();
    }
    rs = (SQLServerResultSet) stmt.executeQuery("SELECT * FROM " + destTable);
    while (rs.next()) {
        // TODO: GetDate has issues
        assertEquals(rs.getString(1), "" + date);
    }
}
Also used : SqlDate(com.microsoft.sqlserver.testframework.sqlType.SqlDate) Date(java.sql.Date) SqlDate(com.microsoft.sqlserver.testframework.sqlType.SqlDate) SQLServerDataTable(com.microsoft.sqlserver.jdbc.SQLServerDataTable) AbstractTest(com.microsoft.sqlserver.testframework.AbstractTest) Test(org.junit.jupiter.api.Test)

Aggregations

SqlDate (com.microsoft.sqlserver.testframework.sqlType.SqlDate)2 SQLServerDataTable (com.microsoft.sqlserver.jdbc.SQLServerDataTable)1 AbstractTest (com.microsoft.sqlserver.testframework.AbstractTest)1 SqlBigInt (com.microsoft.sqlserver.testframework.sqlType.SqlBigInt)1 SqlBinary (com.microsoft.sqlserver.testframework.sqlType.SqlBinary)1 SqlBit (com.microsoft.sqlserver.testframework.sqlType.SqlBit)1 SqlChar (com.microsoft.sqlserver.testframework.sqlType.SqlChar)1 SqlDateTime (com.microsoft.sqlserver.testframework.sqlType.SqlDateTime)1 SqlDateTime2 (com.microsoft.sqlserver.testframework.sqlType.SqlDateTime2)1 SqlDateTimeOffset (com.microsoft.sqlserver.testframework.sqlType.SqlDateTimeOffset)1 SqlDecimal (com.microsoft.sqlserver.testframework.sqlType.SqlDecimal)1 SqlFloat (com.microsoft.sqlserver.testframework.sqlType.SqlFloat)1 SqlInt (com.microsoft.sqlserver.testframework.sqlType.SqlInt)1 SqlMoney (com.microsoft.sqlserver.testframework.sqlType.SqlMoney)1 SqlNChar (com.microsoft.sqlserver.testframework.sqlType.SqlNChar)1 SqlNVarChar (com.microsoft.sqlserver.testframework.sqlType.SqlNVarChar)1 SqlNVarCharMax (com.microsoft.sqlserver.testframework.sqlType.SqlNVarCharMax)1 SqlNumeric (com.microsoft.sqlserver.testframework.sqlType.SqlNumeric)1 SqlReal (com.microsoft.sqlserver.testframework.sqlType.SqlReal)1 SqlSmallDateTime (com.microsoft.sqlserver.testframework.sqlType.SqlSmallDateTime)1