use of java.sql.ParameterMetaData in project phoenix by apache.
the class QueryMetaDataTest method testInListParameterMetaData1.
@Test
public void testInListParameterMetaData1() throws Exception {
String query = "SELECT a_string, b_string FROM atable WHERE a_string IN (?, ?)";
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(String.class.getName(), pmd.getParameterClassName(2));
}
use of java.sql.ParameterMetaData in project phoenix by apache.
the class QueryMetaDataTest method testCaseInsensitive.
@Test
public void testCaseInsensitive() throws Exception {
String query = "SELECT A_string, b_striNG FROM ataBle WHERE ORGANIZATION_ID='000000000000000'";
Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES));
PreparedStatement statement = conn.prepareStatement(query);
ParameterMetaData pmd = statement.getParameterMetaData();
assertEquals(0, pmd.getParameterCount());
}
use of java.sql.ParameterMetaData in project phoenix by apache.
the class QueryMetaDataTest method testLongArithmeticMetaData.
@Test
public void testLongArithmeticMetaData() throws Exception {
String[] ops = { "+", "-", "*", "/" };
for (String op : ops) {
String query = "SELECT entity_id,a_string FROM atable where a_integer" + op + "2" + op + "?=0";
Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES));
PreparedStatement statement = conn.prepareStatement(query);
statement.setInt(1, 4);
ParameterMetaData pmd = statement.getParameterMetaData();
assertEquals(1, pmd.getParameterCount());
assertEquals(Long.class.getName(), pmd.getParameterClassName(1));
}
}
use of java.sql.ParameterMetaData in project phoenix by apache.
the class QueryMetaDataTest method testInListParameterMetaData3.
@Test
public void testInListParameterMetaData3() throws Exception {
String query = "SELECT a_string, b_string FROM atable WHERE ? IN ('foo')";
Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES));
PreparedStatement statement = conn.prepareStatement(query);
ParameterMetaData pmd = statement.getParameterMetaData();
assertEquals(1, pmd.getParameterCount());
assertEquals(String.class.getName(), pmd.getParameterClassName(1));
}
use of java.sql.ParameterMetaData in project phoenix by apache.
the class QueryMetaDataTest method testCoerceToDecimalArithmeticMetaData.
@Test
public void testCoerceToDecimalArithmeticMetaData() throws Exception {
String[] ops = { "+", "-", "*", "/" };
for (String op : ops) {
String query = "SELECT entity_id,a_string FROM atable where a_integer" + op + "2.5" + op + "?=0";
Connection conn = DriverManager.getConnection(getUrl(), PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES));
PreparedStatement statement = conn.prepareStatement(query);
statement.setInt(1, 4);
ParameterMetaData pmd = statement.getParameterMetaData();
assertEquals(1, pmd.getParameterCount());
assertEquals(BigDecimal.class.getName(), pmd.getParameterClassName(1));
}
}
Aggregations