jsqlparser4.5没有getParserConfig()方法
时间: 2023-10-09 15:12:54 浏览: 38
jSQLParser 4.5 版本中的 `getParserConfig()` 方法已经被移除了。可以使用 `CCJSqlParserUtil` 类中的 `getParser()` 方法来获取 `CCJSqlParser` 对象,并通过 `setKeepComments()` 方法来设置是否保留注释。例如:
```java
CCJSqlParserManager pm = new CCJSqlParserManager();
CCJSqlParser parser = pm.getParser(stream);
parser.setKeepComments(true);
```
请注意,jSQLParser 4.5 版本已经过时,建议使用更新的版本。最新版本的 jSQLParser 中提供了许多新的特性和修复了一些 bug。
相关问题
jsqlparser4.5怎么设置标识符引号
在jsqlparser中,可以使用`CCJSqlParserUtil.parse()`方法将SQL语句解析成`Statement`或`Expression`对象。在解析SQL语句时,可以通过设置`CCJSqlParserUtil.setQuoteHandler()`方法来指定标识符引号。
下面是一个例子,演示如何将双引号(`"`)设置为标识符引号:
```java
public class JSqlParserDemo {
public static void main(String[] args) throws JSQLParserException {
String sql = "SELECT * FROM \"my_table\" WHERE \"my_col\" = 123";
CCJSqlParserManager pm = new CCJSqlParserManager();
pm.setQuoteHandler(new DefaultQuoteHandler('"'));
Statement stmt = pm.parse(new StringReader(sql));
System.out.println(stmt);
}
}
```
在上面的例子中,我们使用`DefaultQuoteHandler`来设置标识符引号为双引号(`"`)。输出结果如下:
```
SELECT * FROM "my_table" WHERE "my_col" = 123
```
注意,如果你要设置标识符引号为单引号(`'`),需要将`DefaultQuoteHandler`的参数设置为单引号(`'\''`)。
jsqlparser建的alias没有引号
JSqlParser是一个Java库,用于解析SQL查询语句。如果您使用JSqlParser创建的别名没有引号,这可能是因为您没有在解析器中设置适当的选项。您可以尝试使用以下代码片段来解决这个问题:
```java
CCJSqlParserManager pm = new CCJSqlParserManager();
pm.getParserConfig().setStrictNames(true);
pm.getParserConfig().setIdentifierQuotes('"');
```
这将启用严格名称模式,并将标识符引号设置为双引号。这样,JSqlParser就会在解析别名时添加引号,以确保SQL查询语句的正确性。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)