use of com.alibaba.druid.sql.dialect.mysql.visitor.MySqlExportParameterVisitor in project druid by alibaba.
the class ExportParameters method test_export_parameters.
public void test_export_parameters() throws Exception {
String sql = "select * from t where id = 3 and name = 'abc'";
List<SQLStatement> stmtList = SQLUtils.parseStatements(sql, JdbcConstants.MYSQL);
StringBuilder out = new StringBuilder();
ExportParameterVisitor visitor = new MySqlExportParameterVisitor(out);
for (SQLStatement stmt : stmtList) {
stmt.accept(visitor);
}
String paramteredSql = out.toString();
System.out.println(paramteredSql);
// [3, "abc"]
List<Object> paramters = visitor.getParameters();
for (Object param : paramters) {
System.out.println(param);
}
}
Aggregations