Menu

Driver is inserting square brackets which surround the whole sql statement

Help
2017-06-14
2017-06-14
  • steven mayren

    steven mayren - 2017-06-14

    Hi,

    I am using ucanaccess jdbc driver and connecting to MS Access.

    When I run this code..

    String lDynamicSql = "SELECT orders.customer AS D1, SUM(orders.order_value) AS S1
                            FROM 
                            (   orders orders)
                            GROUP BY orders.customer
                            ORDER BY orders.customer";
    
     pStatement = lConnection.prepareStatement(lDynamicSql);
    

    .. I get the following error:

    net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::4.0.2 unexpected token: ( : line: 3 in statement [SELECT orders.customer AS D1, SUM(orders.ID) AS S1
    FROM 
    (   orders orders)
    GROUP BY orders.customer
    ORDER BY orders.customer]
    

    Any ideas why the driver inserts the square brackets and how do I stop them from being inserted please?

    Thanks for any help as I realise I must be doing something wrong!

     
  • Gord Thompson

    Gord Thompson - 2017-06-14

    Just for debugging purposes, can you try changing

    ... 
    FROM 
    (   orders orders) 
    GROUP BY ...
    

     
    to

    ... 
    FROM 
    orders 
    GROUP BY ...
    

     
    and see if the error goes away?

     
  • steven mayren

    steven mayren - 2017-06-15

    Hi Gord,

    Thanks for the quick reply.

    I tried that and it works.. we don't need the brackets, so that's fine.

    Another developer put the brackets in, so I assume they were needed at some point!??

    Anyway, thanks for your help Gord.

    Steve.

     

Log in to post a comment.

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.