Menu

#32 Helpful error message when attempting to query two tables

open
None
3
2014-08-22
2012-04-09
No

If I try to execute the following two SQL statements:

select s1.id, s2.info from sample1 s1, sample2 s1 where s1.id=s2.id

SELECT * FROM employee LEFT OUTER JOIN department ON employee.DepartmentID = department.DepartmentID

I get the following two exceptions:

java.sql.SQLException: Syntax Error. Encountered " "," ", "" at line 1, column 38.
Was expecting one of:
<EOF>
"WHERE" ...
"ORDER" ...
at org.relique.jdbc.csv.CsvStatement.executeQuery(CsvStatement.java:328)

java.sql.SQLException: Syntax Error. Encountered " <NAME> "OUTER "" at line 1, column 29.
Was expecting one of:
<EOF>
"WHERE" ...
"ORDER" ...

at org.relique.jdbc.csv.CsvStatement.executeQuery(CsvStatement.java:328)

Is it possible to detect these situations and print a more helpful error message like "Queries from more than one table are not supported"?
This will help identify SQL queries that CsvJdbc cannot be used for.

Discussion

  • Simon Chenery

    Simon Chenery - 2012-04-09
    • priority: 5 --> 3
    • assigned_to: nobody --> simoc
     
  • Simon Chenery

    Simon Chenery - 2014-08-11

    Add helpful "not supported" error message if a subquery is used in SQL SELECT statement.

    Files changed:
    src/main/java/org/relique/jdbc/csv/SubQueryExpression.java
    src/main/javacc/org/relique/jdbc/csv/where.jj
    src/main/resources/org/relique/jdbc/csv/messages.properties

     
  • Simon Chenery

    Simon Chenery - 2014-08-16

    Add helpful error message if a cross join (SELECT ... FROM A, B WHERE ...) is used in SQL SELECT statement.

    Files changed:
    src/main/java/org/relique/jdbc/csv/ParsedStatement.java
    src/main/java/org/relique/jdbc/csv/ParsedTable.java
    src/main/java/org/relique/jdbc/csv/SqlParser.java
    src/main/javacc/org/relique/jdbc/csv/where.jj
    src/main/resources/org/relique/jdbc/csv/messages.properties

     
  • Simon Chenery

    Simon Chenery - 2014-08-22

    Add helpful error message if INNER or OUTER joins used in SQL SELECT statment.

    Files changed:
    src/main/java/org/relique/jdbc/csv/JoinType.java
    src/main/java/org/relique/jdbc/csv/ParsedTable.java
    src/main/javacc/org/relique/jdbc/csv/where.jj

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.