Questions tagged [jsqlparser]

JSqlParser is a SQL statement parser. It translates SQLs in a traversable hierarchy of Java classes.

About

JSqlParser is a SQL statement parser. It translates SQLs in a traversable hierarchy of Java classes.

JSqlParser is not limited to one database but provides support for a lot of specials of Oracle, SqlServer, MySQL, PostgreSQL ...

To name some, it has support for Oracles join syntax using (+), PostgreSQLs cast syntax using ::, relational operators like != and so on.

Links

60 questions
8
votes
1 answer

JSqlParser - Getting table name from Column

I have just started to explore JSqlparser. According to my understanding, I have modified the TablesNamesFinder to extract columns and tables and its working fine but a very small problem. @Override public void visit(Column col) { Column c =…
Waleed
  • 1,097
  • 18
  • 45
8
votes
3 answers

How to retrieve table and column names from SQl using JSQLPARSE

I am using JSQLPARSER for the first time. I have some SQL files which come dynamically, i need to read table and column names from that SQL. After lot of googling I tried with JSQLPARSER. I am trying to read column names from the file but I am…
Navyah
  • 1,660
  • 10
  • 33
  • 58
4
votes
2 answers

Fully parsing where clause with JSqlParser

I would like to completely, and succinctly, parse a SQL where clause using JSqlParser. It's easy to parse it into individual conditional statements like so String whereClause = "a=3 AND b=4 AND c=5"; Expression expr =…
codering
  • 55
  • 1
  • 5
4
votes
1 answer

Parsing table and column names from SQL/HQL Java

I am looking for an open source API in Java to parse an SQL / HQL query so that it gives me the column names and the table names used in it. I tried using JSQLParser which gives me the table names used in the query. But I don't see a support for…
Lisa
  • 63
  • 1
  • 5
3
votes
0 answers

use JavaCC to format my input file; how to handle comments?

I'm parsing SQL using the excellen JSQLParser library, which uses JavaCC internally. The grammar consists of TOKENs and SPECIAL_TOKENs. The latter is used to remove the single and multi-line comments from the token stream before the parser is…
Rob Audenaerde
  • 19,195
  • 10
  • 76
  • 121
3
votes
1 answer

How to add where condition to sql with JSqlParser?

I want to add where condition to sql with JSqlParser, for example: Before: select * from test_table where a=1 group by c After: select * from test_table where a=1 and b=2 group by c However, I cannot find any example codes.
3
votes
2 answers

Get Table names and Query types from sql statement in JAVA

I am new to jsqlparser and trying to parse the sql statement to get table name and its query type (In Java). For eg1. INSERT INTO Customers (CustomerName, Country) SELECT SupplierName, Country FROM Suppliers WHERE…
Amaresh Narayanan
  • 4,159
  • 3
  • 20
  • 22
2
votes
1 answer

Recognizing function calls in SQL with JSQLParser

How can I distinguish function calls and field names using JSQLParser? For example, the query SELECT COUNT(*) FROM db.table parses COUNT(*) as a field name and not a function call. What do I need to do to change the SQL parsing to show COUNT(*) as a…
max
  • 2,346
  • 4
  • 26
  • 34
2
votes
1 answer

How to add new condition with JSqlParser?

I want to add new condition to my sql. For example If query is; SELECT EMP_ID, FIRST_NAME FROM EMPLOYEES; I can add new where cause with this codes; @Override protected void setLimit(final PlainSelect ps,final long rowLimit) { Expression where…
displayname
  • 148
  • 1
  • 15
2
votes
1 answer

JSQL Parser - Info on parsing functions

Can JSQLParser differentiate between View/Function/Table in a SELECT query ? If for example, executing a function in the following ways: select * from public.new(10); select public.new(10); Is it possible for JSQL to figure out that it is executing…
2
votes
1 answer

JSqlParser - Pretty print where clause

I have started to use JSqlParser, i can parse a Where clause but i don't manage to go further with it. JSqlParser github link Indeed, i have tried to Override visit methods but don't understand how to reach my goal. Let's say i have: (a=1 AND (b=2…
Bi-JOE
  • 21
  • 3
2
votes
2 answers

javac CLASSPATH issue

This seems to be very trivial. But I'm stuck for a while. My CLASSPATH: jerry@jerry-OptiPlex-790:~/Desktop/SQLLite-experiment/java$ echo $CLASSPATH .:./*:/home/jerry/Desktop/SQLLite-experiment/java/jsqlparser-0.7.0.jar Output of…
Jerry Ajay
  • 1,084
  • 11
  • 26
1
vote
1 answer

How to add new column to select statement with JSqlParser

This is my sql statement. String sql = "select mydate from mytable"; How can i add new columns to it dynamically with JSqlParser? For example i want to add "mylocation" column to my sql query: String sql = "select mydate, mylocation from mytable";
Ali Atıl
  • 121
  • 7
1
vote
0 answers

How to validate unpivot sql query in jsqlparser?

I want to execute query which contains unpivot in springboot application. We are using jSqlparser to validate the syntax of the query. jsqlparser version is 1.4. This version reject unpivot. Anyone can please help on this? String sql = select ctype,…
Rosh
  • 730
  • 2
  • 12
  • 32
1
vote
1 answer

How to handle '[ ] -' characters on JSqlParser

I am using JSqlParser 3.0 and my query is SELECT * from [dev-testdb].dbo.EMPLOYEES. I am trying to remove [] characters because JSqlParser 3.0 version is not supported for these characters.I guess 1.x does but I have to use 3.0. After remove…
displayname
  • 148
  • 1
  • 15
1
2 3 4