本文整理汇总了Java中net.sf.jsqlparser.expression.JdbcParameter类的典型用法代码示例。如果您正苦于以下问题:Java JdbcParameter类的具体用法?Java JdbcParameter怎么用?Java JdbcParameter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JdbcParameter类属于net.sf.jsqlparser.expression包,在下文中一共展示了JdbcParameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visit
import net.sf.jsqlparser.expression.JdbcParameter; //导入依赖的package包/类
@Override
public void visit(JdbcParameter parameter)
{
Object value = parameterStore.getParameter(parameter.getIndex());
parameterStore.setColumn(parameter.getIndex(), column);
setValue(value);
}
示例2: setWhereParameters
import net.sf.jsqlparser.expression.JdbcParameter; //导入依赖的package包/类
private void setWhereParameters(Expression where, com.google.cloud.spanner.Statement.Builder builder)
{
if (where != null)
{
where.accept(new ExpressionVisitorAdapter()
{
private String currentCol = null;
@Override
public void visit(Column col)
{
currentCol = unquoteIdentifier(col.getFullyQualifiedName());
}
@Override
public void visit(JdbcParameter parameter)
{
parameter.accept(new ValueBinderExpressionVisitorAdapter<>(getParameterStore(),
builder.bind("p" + parameter.getIndex()), currentCol));
currentCol = null;
}
@Override
public void visit(SubSelect subSelect)
{
setSelectParameters(subSelect.getSelectBody(), builder);
}
});
}
}
示例3: visit
import net.sf.jsqlparser.expression.JdbcParameter; //导入依赖的package包/类
@Override
public void visit(JdbcParameter jdbcParameter) {
buffer.append("?");
if (jdbcParameter.getIndex() != null) {
buffer.append(jdbcParameter.getIndex());
}
}
示例4: isConstant
import net.sf.jsqlparser.expression.JdbcParameter; //导入依赖的package包/类
static boolean isConstant(Expression exp) {
return exp instanceof StringValue
|| exp instanceof LongValue
|| exp instanceof NullValue
|| exp instanceof TimestampValue
|| exp instanceof JdbcParameter;
}
示例5: resolveValue
import net.sf.jsqlparser.expression.JdbcParameter; //导入依赖的package包/类
private static Object resolveValue(Expression expression, boolean allowColumn) throws StatementExecutionException {
if (expression instanceof JdbcParameter) {
throw new StatementExecutionException("jdbcparameter expression not usable in this query");
} else if (allowColumn && expression instanceof net.sf.jsqlparser.schema.Column) {
// this is only for supporting back ticks in DDL
return ((net.sf.jsqlparser.schema.Column) expression).getColumnName();
} else if (expression instanceof StringValue) {
return ((StringValue) expression).getValue();
} else if (expression instanceof LongValue) {
return ((LongValue) expression).getValue();
} else if (expression instanceof TimestampValue) {
return ((TimestampValue) expression).getValue();
} else if (expression instanceof SignedExpression) {
SignedExpression se = (SignedExpression) expression;
switch (se.getSign()) {
case '+': {
return resolveValue(se.getExpression(), allowColumn);
}
case '-': {
Object value = resolveValue(se.getExpression(), allowColumn);
if (value == null) {
return null;
}
if (value instanceof Integer) {
return -1L * ((Integer) value);
} else if (value instanceof Long) {
return -1L * ((Long) value);
} else {
throw new StatementExecutionException("unsupported value type " + expression.getClass() + " with sign " + se.getSign() + " on value " + value + " of type " + value.getClass());
}
}
default:
throw new StatementExecutionException("unsupported value type " + expression.getClass() + " with sign " + se.getSign());
}
} else {
throw new StatementExecutionException("unsupported value type " + expression.getClass());
}
}
示例6: visitLimit
import net.sf.jsqlparser.expression.JdbcParameter; //导入依赖的package包/类
private void visitLimit(Limit limit) {
if (limit.getOffset() != null) {
if (limit.getOffset() instanceof JdbcParameter) {
limit.setOffset(ImmutableExpressionsCache.internOrFixJdbcParameterExpression((JdbcParameter) limit.getOffset()));
}
limit.getOffset().accept(this);
}
if (limit.getRowCount() != null) {
if (limit.getRowCount() instanceof JdbcParameter) {
limit.setRowCount(ImmutableExpressionsCache.internOrFixJdbcParameterExpression((JdbcParameter) limit.getRowCount()));
}
limit.getRowCount().accept(this);
}
}
示例7: visitBinaryExpression
import net.sf.jsqlparser.expression.JdbcParameter; //导入依赖的package包/类
private void visitBinaryExpression(BinaryExpression e) {
if (e.getLeftExpression() instanceof JdbcParameter) {
e.setLeftExpression(ImmutableExpressionsCache.internOrFixJdbcParameterExpression((JdbcParameter) e.getLeftExpression()));
}
if (e.getRightExpression() instanceof JdbcParameter) {
e.setRightExpression(ImmutableExpressionsCache.internOrFixJdbcParameterExpression((JdbcParameter) e.getRightExpression()));
}
e.getLeftExpression().accept(this);
e.getRightExpression().accept(this);
}
示例8: visit
import net.sf.jsqlparser.expression.JdbcParameter; //导入依赖的package包/类
@Override
public void visit(ExpressionList expressionList) {
List<Expression> expressions = expressionList.getExpressions();
int size = expressions.size();
for (int i = 0; i < size; i++) {
Expression e = expressions.get(i);
if (e instanceof JdbcParameter) {
e = ImmutableExpressionsCache.internOrFixJdbcParameterExpression((JdbcParameter) e);
}
expressions.set(i, e);
e.accept(this);
}
}
示例9: testReplaceSyntax1
import net.sf.jsqlparser.expression.JdbcParameter; //导入依赖的package包/类
public void testReplaceSyntax1() throws JSQLParserException {
String statement = "REPLACE mytable SET col1='as', col2=?, col3=565";
Replace replace = (Replace) parserManager.parse(new StringReader(statement));
assertEquals("mytable", replace.getTable().getName());
assertEquals(3, replace.getColumns().size());
assertEquals("col1", ((Column) replace.getColumns().get(0)).getColumnName());
assertEquals("col2", ((Column) replace.getColumns().get(1)).getColumnName());
assertEquals("col3", ((Column) replace.getColumns().get(2)).getColumnName());
assertEquals("as", ((StringValue)replace.getExpressions().get(0)).getValue());
assertTrue(replace.getExpressions().get(1) instanceof JdbcParameter);
assertEquals(565, ((LongValue)replace.getExpressions().get(2)).getValue());
assertEquals(statement, ""+replace);
}
示例10: testReplaceSyntax2
import net.sf.jsqlparser.expression.JdbcParameter; //导入依赖的package包/类
public void testReplaceSyntax2() throws JSQLParserException {
String statement = "REPLACE mytable (col1, col2, col3) VALUES ('as', ?, 565)";
Replace replace = (Replace) parserManager.parse(new StringReader(statement));
assertEquals("mytable", replace.getTable().getName());
assertEquals(3, replace.getColumns().size());
assertEquals("col1", ((Column) replace.getColumns().get(0)).getColumnName());
assertEquals("col2", ((Column) replace.getColumns().get(1)).getColumnName());
assertEquals("col3", ((Column) replace.getColumns().get(2)).getColumnName());
assertEquals("as", ((StringValue) ((ExpressionList)replace.getItemsList()).getExpressions().get(0)).getValue());
assertTrue(((ExpressionList)replace.getItemsList()).getExpressions().get(1) instanceof JdbcParameter);
assertEquals(565, ((LongValue) ((ExpressionList)replace.getItemsList()).getExpressions().get(2)).getValue());
assertEquals(statement, ""+replace);
}
示例11: testUpdate
import net.sf.jsqlparser.expression.JdbcParameter; //导入依赖的package包/类
public void testUpdate() throws JSQLParserException {
String statement = "UPDATE mytable set col1='as', col2=?, col3=565 Where o >= 3";
Update update = (Update) parserManager.parse(new StringReader(statement));
assertEquals("mytable", update.getTable().getName());
assertEquals(3, update.getColumns().size());
assertEquals("col1", ((Column) update.getColumns().get(0)).getColumnName());
assertEquals("col2", ((Column) update.getColumns().get(1)).getColumnName());
assertEquals("col3", ((Column) update.getColumns().get(2)).getColumnName());
assertEquals("as", ((StringValue) update.getExpressions().get(0)).getValue());
assertTrue(update.getExpressions().get(1) instanceof JdbcParameter);
assertEquals(565, ((LongValue) update.getExpressions().get(2)).getValue());
assertTrue(update.getWhere() instanceof GreaterThanEquals);
}
示例12: testReplaceSyntax1
import net.sf.jsqlparser.expression.JdbcParameter; //导入依赖的package包/类
@Test
public void testReplaceSyntax1() throws JSQLParserException {
String statement = "REPLACE mytable SET col1='as', col2=?, col3=565";
Replace replace = (Replace) parserManager.parse(new StringReader(statement));
assertEquals("mytable", replace.getTable().getName());
assertEquals(3, replace.getColumns().size());
assertEquals("col1", ((Column) replace.getColumns().get(0)).getColumnName());
assertEquals("col2", ((Column) replace.getColumns().get(1)).getColumnName());
assertEquals("col3", ((Column) replace.getColumns().get(2)).getColumnName());
assertEquals("as", ((StringValue) replace.getExpressions().get(0)).getValue());
assertTrue(replace.getExpressions().get(1) instanceof JdbcParameter);
assertEquals(565, ((LongValue) replace.getExpressions().get(2)).getValue());
assertEquals(statement, "" + replace);
}
示例13: testReplaceSyntax2
import net.sf.jsqlparser.expression.JdbcParameter; //导入依赖的package包/类
@Test
public void testReplaceSyntax2() throws JSQLParserException {
String statement = "REPLACE mytable (col1, col2, col3) VALUES ('as', ?, 565)";
Replace replace = (Replace) parserManager.parse(new StringReader(statement));
assertEquals("mytable", replace.getTable().getName());
assertEquals(3, replace.getColumns().size());
assertEquals("col1", ((Column) replace.getColumns().get(0)).getColumnName());
assertEquals("col2", ((Column) replace.getColumns().get(1)).getColumnName());
assertEquals("col3", ((Column) replace.getColumns().get(2)).getColumnName());
assertEquals("as", ((StringValue) ((ExpressionList) replace.getItemsList()).getExpressions().get(0)).getValue());
assertTrue(((ExpressionList) replace.getItemsList()).getExpressions().get(1) instanceof JdbcParameter);
assertEquals(565, ((LongValue) ((ExpressionList) replace.getItemsList()).getExpressions().get(2)).getValue());
assertEquals(statement, "" + replace);
}
示例14: testUpdate
import net.sf.jsqlparser.expression.JdbcParameter; //导入依赖的package包/类
@Test
public void testUpdate() throws JSQLParserException {
String statement = "UPDATE mytable set col1='as', col2=?, col3=565 Where o >= 3";
Update update = (Update) parserManager.parse(new StringReader(statement));
assertEquals("mytable", update.getTable().getName());
assertEquals(3, update.getColumns().size());
assertEquals("col1", ((Column) update.getColumns().get(0)).getColumnName());
assertEquals("col2", ((Column) update.getColumns().get(1)).getColumnName());
assertEquals("col3", ((Column) update.getColumns().get(2)).getColumnName());
assertEquals("as", ((StringValue) update.getExpressions().get(0)).getValue());
assertTrue(update.getExpressions().get(1) instanceof JdbcParameter);
assertEquals(565, ((LongValue) update.getExpressions().get(2)).getValue());
assertTrue(update.getWhere() instanceof GreaterThanEquals);
}
示例15: getInstance
import net.sf.jsqlparser.expression.JdbcParameter; //导入依赖的package包/类
public static Projector getInstance(Expression expression, String alias, QueryTypeExtractor queryTypeExtractor) {
Projector instance = null;
if (expression instanceof net.sf.jsqlparser.schema.Column) {
instance = new ColumnProjector((net.sf.jsqlparser.schema.Column) expression, alias, queryTypeExtractor);
} else if (expression instanceof Function) {
instance = new FunctionProjector((Function) expression, alias, queryTypeExtractor);
} else if (expression instanceof BinaryExpression) {
instance = new BinaryExpressionProjector((BinaryExpression) expression, alias, queryTypeExtractor);
} else if (expression instanceof LongValue) {
instance = new LongProjector(expression, alias, queryTypeExtractor);
} else if (expression instanceof StringValue) {
instance = new StringProjector(expression, alias, queryTypeExtractor);
} else if (expression instanceof DoubleValue) {
instance = new DoubleProjector(expression, alias, queryTypeExtractor);
} else if (expression instanceof Parenthesis) {
instance = new ParenthesisProjector((Parenthesis) expression, queryTypeExtractor);
} else if (expression instanceof JdbcParameter) {
instance = new JdbcParameterProjector(queryTypeExtractor);
} else if (expression instanceof SubSelect) {
instance = new SubSelectProjector((SubSelect) expression, alias, queryTypeExtractor);
} else {
throw new RuntimeException("Not supported");
}
return instance;
}