Search in sources :

Example 71 with ParameterMetaData

use of java.sql.ParameterMetaData in project phoenix by apache.

the class QueryMetaDataTest method testRowValueConstructorBindParamMetaDataWithMoreNumberOfBindArgs.

@Test
public void testRowValueConstructorBindParamMetaDataWithMoreNumberOfBindArgs() throws Exception {
    String query = "SELECT a_integer, x_integer FROM aTable WHERE (a_integer, x_integer) = (?, ?, ?)";
    Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES));
    PreparedStatement statement = conn.prepareStatement(query);
    ParameterMetaData pmd = statement.getParameterMetaData();
    assertEquals(3, pmd.getParameterCount());
    assertEquals(Integer.class.getName(), pmd.getParameterClassName(1));
    assertEquals(Integer.class.getName(), pmd.getParameterClassName(2));
    assertEquals(null, pmd.getParameterClassName(3));
}
Also used : Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) ParameterMetaData(java.sql.ParameterMetaData) Test(org.junit.Test) BaseConnectionlessQueryTest(org.apache.phoenix.query.BaseConnectionlessQueryTest)

Example 72 with ParameterMetaData

use of java.sql.ParameterMetaData in project phoenix by apache.

the class QueryMetaDataTest method testDateAdditionExpressionMetaData1.

@Test
public void testDateAdditionExpressionMetaData1() throws Exception {
    String query = "SELECT entity_id,a_string FROM atable where 1+a_date+?>a_date";
    Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES));
    PreparedStatement statement = conn.prepareStatement(query);
    ParameterMetaData pmd = statement.getParameterMetaData();
    assertEquals(1, pmd.getParameterCount());
    assertEquals(BigDecimal.class.getName(), pmd.getParameterClassName(1));
}
Also used : Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) ParameterMetaData(java.sql.ParameterMetaData) BigDecimal(java.math.BigDecimal) Test(org.junit.Test) BaseConnectionlessQueryTest(org.apache.phoenix.query.BaseConnectionlessQueryTest)

Example 73 with ParameterMetaData

use of java.sql.ParameterMetaData in project phoenix by apache.

the class QueryMetaDataTest method testRowValueConstructorBindParamMetaDataWithBindArgsOnLHSAndLiteralExprOnRHS.

// @Test broken currently, as we'll end up with null = 7 which is never true
public void testRowValueConstructorBindParamMetaDataWithBindArgsOnLHSAndLiteralExprOnRHS() throws Exception {
    String query = "SELECT a_integer, x_integer FROM aTable WHERE (?, ?) = 7";
    Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES));
    PreparedStatement statement = conn.prepareStatement(query);
    ParameterMetaData pmd = statement.getParameterMetaData();
    assertEquals(2, pmd.getParameterCount());
    assertEquals(Integer.class.getName(), pmd.getParameterClassName(1));
    assertEquals(null, pmd.getParameterClassName(2));
}
Also used : Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) ParameterMetaData(java.sql.ParameterMetaData)

Example 74 with ParameterMetaData

use of java.sql.ParameterMetaData in project phoenix by apache.

the class QueryMetaDataTest method testLimitParameterMetaData.

@Test
public void testLimitParameterMetaData() throws Exception {
    String query = "SELECT a_string, b_string FROM atable WHERE organization_id=? and a_string = 'foo' LIMIT ?";
    Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES));
    PreparedStatement statement = conn.prepareStatement(query);
    ParameterMetaData pmd = statement.getParameterMetaData();
    assertEquals(2, pmd.getParameterCount());
    assertEquals(String.class.getName(), pmd.getParameterClassName(1));
    assertEquals(Integer.class.getName(), pmd.getParameterClassName(2));
}
Also used : Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) ParameterMetaData(java.sql.ParameterMetaData) Test(org.junit.Test) BaseConnectionlessQueryTest(org.apache.phoenix.query.BaseConnectionlessQueryTest)

Example 75 with ParameterMetaData

use of java.sql.ParameterMetaData in project phoenix by apache.

the class QueryMetaDataTest method testInListParameterMetaData4.

@Test
public void testInListParameterMetaData4() throws Exception {
    String query = "SELECT a_string, b_string FROM atable WHERE ? IN (?, ?)";
    Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES));
    PreparedStatement statement = conn.prepareStatement(query);
    ParameterMetaData pmd = statement.getParameterMetaData();
    assertEquals(3, pmd.getParameterCount());
    assertEquals(null, pmd.getParameterClassName(1));
    assertEquals(null, pmd.getParameterClassName(2));
    assertEquals(null, pmd.getParameterClassName(3));
}
Also used : Connection(java.sql.Connection) PreparedStatement(java.sql.PreparedStatement) ParameterMetaData(java.sql.ParameterMetaData) Test(org.junit.Test) BaseConnectionlessQueryTest(org.apache.phoenix.query.BaseConnectionlessQueryTest)

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