Search in sources :

Example 1 with SQLServerParameterMetaData

use of com.microsoft.sqlserver.jdbc.SQLServerParameterMetaData in project mssql-jdbc by Microsoft.

the class PQImpsTest method testComplexQueryWithMultipleTables.

/**
 * test getting parameter count with a complex query with multiple table
 *
 * @throws SQLException
 */
@Test
public void testComplexQueryWithMultipleTables() throws SQLException {
    pstmt = connection.prepareStatement("insert into " + charTable + " (c1) select ? where not exists (select * from " + charTable2 + " where table2c1 = ?)");
    try {
        SQLServerParameterMetaData pMD = (SQLServerParameterMetaData) pstmt.getParameterMetaData();
        int parameterCount = pMD.getParameterCount();
        assertTrue(2 == parameterCount, "Parameter Count should be 2.");
    } catch (Exception e) {
        fail(e.toString());
    }
}
Also used : SQLServerParameterMetaData(com.microsoft.sqlserver.jdbc.SQLServerParameterMetaData) SQLException(java.sql.SQLException) Test(org.junit.jupiter.api.Test) AbstractTest(com.microsoft.sqlserver.testframework.AbstractTest)

Aggregations

SQLServerParameterMetaData (com.microsoft.sqlserver.jdbc.SQLServerParameterMetaData)1 AbstractTest (com.microsoft.sqlserver.testframework.AbstractTest)1 SQLException (java.sql.SQLException)1 Test (org.junit.jupiter.api.Test)1