Menu

wtf: mysql anomaly?!?

Help
2008-03-30
2013-04-25
  • Matt Stucky

    Matt Stucky - 2008-03-30

    ok found a workaround to this but I'm wondering if any of you guys familiar with sql2java internals can tell me why.

    mysql version 5
    database named proto_alpha
    table named 'thread' - not the best I know but it's a forum-type application

    everything works great until i add a column named 'reads' type integer.  after that my ThreadManager can't load any generated ThreadBean objects.

    if i change the column to 'xreads' or 'read_count' all goes back to working fine.

    since MySQL allows the column name and i can't see java having a problem with 'getReads' and 'setReads' methods etc, i'm left assuming sql2java has a problem with it

    anyone care to tell me why?

    still, this is a great product, i'm loving using it

    matt

     
    • Alain Fagot Béarez

      Giving it a try with the MS SQL server, I brought the Enterprise Manager to crash when trying to take a look at the table I create via the command line isql.  But my Java program is just working fine.  ;-)

      Giving it a try with the Mysql 5.0.45, I got (through debugging because the DAOException is occulting the root cause message) the following error message:

      You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'reads) values (77)' at line 1

      on the following statement:

      INSERT into thread (reads) values (?)

      Thanks for reporting this, even if I really can't solve your problem. At least in the next release, you'll get informed of the syntactic error generated by the use of the 'reads' word as a column name.

      I will patch the generated DAOException class to let it show the original error message it got.

      Best regards,
      Alain

       
    • Matt Stucky

      Matt Stucky - 2008-04-10

      just a follow up:

      1.  looks like any MySQL reserved word has the same effect... a table with columns named 'key' and 'value' showed the same behavior

      2.  could it be fixed by putting "back-tick" operators around the name, that's how MySQL allows reserved words to be column names, also how spaces in names are handled.  does anyone know if this has been tried?

      I'll be happy to do the patch and submit the code, but i know v3 is in the works, i'll wait if it will be better to do so until the new version is stable.

      matt

       
      • Alain Fagot Béarez

        Hi Matt,

        Please prepare the patch and submit it in the patch tracker section:
        http://sourceforge.net/tracker/?group_id=54687&atid=474469

        Please keep in mind that you should make it ready for other database engines as well. If at all possible. ;-)

        Thanks for your help,
        Alain

         

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.