My own WTF. Query the database for info in the parameters.



  • I jut found this little nugget of code, that I wrote about a year and a half ago, in the database handler (which iis basically a broker for the rest of the core and every database request goes through it). The only thing I can think is that I wanted to make sure the customer is actually in the database before I created the Customer object.

    public Customer getCustomer(String customerID)
     {
       Customer outgoing = new Customer("");
       setResultSet("SELECT strCustomerID FROM `tblARCustomer` WHERE strCustomerID='" + customerID + "'");
       try
       {
        if (resultSet.first())
         outgoing.setCustomerID(resultSet.getString(1));
       }
       catch(Exception e)
        {e.printStackTrace();}

       return outgoing;
      }
    [/code]



  • TRWTF is using e.printStackTrace() instead of logging the exception.



  • "1"; DROP TABLE `tblARCustomer`;

    :)



  • I don't have a logging server setup. This was just a proof-of-concept for my boss. I'm trying to get us away from using Access 2000/VBA and into Java or .NET.



  • @captainpants said:

    ; DROP TABLE tblARCustomer;

    :)

    You forgot to end it with "--". ;)



  • @Gazzonyx said:

       setResultSet("SELECT strCustomerID FROM tblARCustomer WHERE strCustomerID='" + customerID + "'");

    TRWTF is not using prepared statements. TRWTF is not closing the connection. TRWTF is that resultSet is an instance filed... damn! I hope you learned the lesson!



  • TBH, I think I have the actual query as a view over on the MySQL server.
    Why would I close the connection? I'm just going to be using this Class to execute another query as soon as I get the Customer. ResultSet is a private member of the DatabaseHandler.

    Once again, this is just a proof of concept for moving over to MySQL, but I'm curious if I've modeled the entire thing wrong. Essentially I've modeled it so that the DatabaseHandler (in the future it'd run in its own Thread) sits at the core and services all access to the database and only passes back Objects that model the data. For instance, if you want a Customer Object, you ask for it by its customerID and you get the Object that represents that Customer. If you want the locations (shipto, billto, etc) for it, you pass the Customer object to the DatabaseHandler and it fills in that part of the Customer object. Is this a sensible design?



  • @Gazzonyx said:

    (in the future it'd run in its own Thread)

    ??? This is the only nonsensical part of your stated design. Why would this run on another thread (or, on any given thread at all)?



  • @pkmnfrk said:

    @Gazzonyx said:
    (in the future it'd run in its own Thread)

    ??? This is the only nonsensical part of your stated design. Why would this run on another thread (or, on any given thread at all)?

    'main' is a thread :)



  • @pkmnfrk said:

    @Gazzonyx said:
    (in the future it'd run in its own Thread)

    ??? This is the only nonsensical part of your stated design. Why would this run on another thread (or, on any given thread at all)?

    IIRC I wanted to make the code so that I could take the DatabaseHandler and migrate it to the backend from the frontend. The only reason I said that was because I had a comment: /** BB Move this to its own Thread */. I assume I had a reason at the time. :)


  • If a call from UI code makes its way into the DatabaseHandler without it running on another thread, and the query takes any significant period of time (tens of thousands of records, or slow WAN link, or having to build a tunnel, or...), then the UI will freeze for the duration of the query. Thus, the database access should be moved to its own thread.

    Of course, just doing that isn't enough, since now the UI thread will be waiting on the DB thread to finish its task, and the perceived freeze will still arise. To combat that, you need to use some sort of asynchronicity, such as the completion routine pattern (pass in an anonymous function, a Function object obtained through reflection, or some interface implementation, which the DB thread will then call into when it has finished its work), which makes things even more complicated.



  • @TwelveBaud said:

    If a call from UI code makes its way into the DatabaseHandler without it running on another thread, and the query takes any significant period of time (tens of thousands of records, or slow WAN link, or having to build a tunnel, or...), then the UI will freeze for the duration of the query. Thus, the database access should be moved to its own thread.

    Of course, just doing that isn't enough, since now the UI thread will be waiting on the DB thread to finish its task, and the perceived freeze will still arise. To combat that, you need to use some sort of asynchronicity, such as the completion routine pattern (pass in an anonymous function, a Function object obtained through reflection, or some interface implementation, which the DB thread will then call into when it has finished its work), which makes things even more complicated.

    My assumption was that this is server-side.



  • @TwelveBaud said:

    If a call from UI code makes its way into the DatabaseHandler without it running on another thread, and the query takes any significant period of time (tens of thousands of records, or slow WAN link, or having to build a tunnel, or...), then the UI will freeze for the duration of the query. Thus, the database access should be moved to its own thread.

    Of course, just doing that isn't enough, since now the UI thread will be waiting on the DB thread to finish its task, and the perceived freeze will still arise. To combat that, you need to use some sort of asynchronicity, such as the completion routine pattern (pass in an anonymous function, a Function object obtained through reflection, or some interface implementation, which the DB thread will then call into when it has finished its work), which makes things even more complicated.

    It's not that hard. I've done this before. I usually implement an interface that has a "public Boolean workCompleted" that all of the callers implement. They do a wait on a lock object and then sit there until the called thread comes back and calls their workCompleted() which does a notifyAll(). Although, if done incorrectly this is still racy.



  • @morbiuswilters said:

    My assumption was that this is server-side.

    Right now it's living in client-land because I'm just proving it can work. It's abstracted enough that it shouldn't be a problem to move it server side if I get a green light for moving it to production.


  • ♿ (Parody)

    @Gazzonyx said:

    @morbiuswilters said:
    My assumption was that this is server-side.

    Right now it's living in client-land because I'm just proving it can work. It's abstracted enough that it shouldn't be a problem to move it server side if I get a green light for moving it to production.

    Jeez, why does everyone insist on reinventing the wheel? This is a solved problem.



  • @boomzilla said:

    @Gazzonyx said:
    @morbiuswilters said:
    My assumption was that this is server-side.

    Right now it's living in client-land because I'm just proving it can work. It's abstracted enough that it shouldn't be a problem to move it server side if I get a green light for moving it to production.

    Jeez, why does everyone insist on reinventing the wheel? This is a solved problem.


    That'd work fine other than it's not Java and doesn't run on Linux.
    Also, the licensing terms aren't that friendly for me during prototyping. "System‑G is not currently available for licensing. We are still considering our options."
    What does System-G bring to the plate? It seems like a square wheel to me.



  • @Gazzonyx said:

    @boomzilla said:
    @Gazzonyx said:
    @morbiuswilters said:
    My assumption was that this is server-side.

    Right now it's living in client-land because I'm just proving it can work. It's abstracted enough that it shouldn't be a problem to move it server side if I get a green light for moving it to production.

    Jeez, why does everyone insist on reinventing the wheel? This is a solved problem.


    That'd work fine other than it's not Java and doesn't run on Linux.
    Also, the licensing terms aren't that friendly for me during prototyping. "System‑G is not currently available for licensing. We are still considering our options."
    What does System-G bring to the plate? It seems like a square wheel to me.

    He was joking. Because, as noted on another thread, System G is an ugly pile of crap.



  • @morbiuswilters said:

    @Gazzonyx said:
    @boomzilla said:
    @Gazzonyx said:
    @morbiuswilters said:
    My assumption was that this is server-side.

    Right now it's living in client-land because I'm just proving it can work. It's abstracted enough that it shouldn't be a problem to move it server side if I get a green light for moving it to production.

    Jeez, why does everyone insist on reinventing the wheel? This is a solved problem.


    That'd work fine other than it's not Java and doesn't run on Linux.
    Also, the licensing terms aren't that friendly for me during prototyping. "System‑G is not currently available for licensing. We are still considering our options."
    What does System-G bring to the plate? It seems like a square wheel to me.

    He was joking. Because, as noted on another thread, System G is an ugly pile of crap.


    Oh. I see.

    • <--- Joke

       O

      /|\ <--- Me

      / <BR>
      WOOSH!


  • @Gazzonyx said:

    @morbiuswilters said:
    @Gazzonyx said:
    @boomzilla said:
    @Gazzonyx said:
    @morbiuswilters said:
    My assumption was that this is server-side.

    Right now it's living in client-land because I'm just proving it can work. It's abstracted enough that it shouldn't be a problem to move it server side if I get a green light for moving it to production.

    Jeez, why does everyone insist on reinventing the wheel? This is a solved problem.


    That'd work fine other than it's not Java and doesn't run on Linux.
    Also, the licensing terms aren't that friendly for me during prototyping. "System‑G is not currently available for licensing. We are still considering our options."
    What does System-G bring to the plate? It seems like a square wheel to me.

    He was joking. Because, as noted on another thread, System G is an ugly pile of crap.


    Oh. I see.

    • <--- Joke

       O

      /|\ <--- Me

      / <br>
      WOOSH!
     

     

    Actually, it mostly just proves you don't live on TDWTF forums or you'd know about SystemG :)



  • @Shinhan7 said:

    @Gazzonyx said:


    • <--- Joke

       O

      /|\ <--- Me

      / <br>
      WOOSH!
     

     Actually, it mostly just proves you don't live on TDWTF forums or you'd know about SystemG :)

    And a mod (that may or may not live in the shadows) may be along to Rosie his xkcd attempt before morb's cheek begins its nervous tic...



  • @Cassidy said:

    @Shinhan7 said:

    @Gazzonyx said:


    • <--- Joke

       O

      /|\ <--- Me

      / <br>
      WOOSH!
     

     Actually, it mostly just proves you don't live on TDWTF forums or you'd know about SystemG :)

    And a mod (that may or may not live in the shadows) may be along to Rosie his xkcd attempt before morb's cheek begins its nervous tic...


    I've been a lurker here for years, but I haven't really started participating until recently. I'm working on a project that's full of delicious nutty WTF flavor. As for my ASCII art, what do you mean by "Rosie my XKCD attempt"? Does Morisbund have a thing for ASCII art?

  • Discourse touched me in a no-no place

    @Cassidy said:

    And a mod (that may or may not live in the shadows) may be along to Rosie his xkcd attempt before morb's cheek begins its nervous tic...
    What xkcd attempt?



  • @zelmak said:

    @pkmnfrk said:

    @Gazzonyx said:
    (in the future it'd run in its own Thread)

    ??? This is the only nonsensical part of your stated design. Why would this run on another thread (or, on any given thread at all)?

    'main' is a thread :)

    If you want to get into a pedantry war, then by all means :)

    'main' is a function, typically the entry point of console-mode applications written in C or otherwise linked the C standard library. It generally runs on the first thread in an application, which itself may or may not be named "main" (but I don't think it does this by default).



  • @Gazzonyx said:

    As for my ASCII art, what do you mean by "Rosie my XKCD attempt"?

    It was a feeble attempt at humour, and a reference to XKCD images being replaced with Rosie O'Donnell.

    @Gazzonyx said:

    Does Morisbund have a thing for ASCII art?

    No, XKCD. Check other threads for that.

    Or just post one and stand welllllllllllllllllllll back.



  • Oh. Wow. http://forums.thedailywtf.com/forums/p/25782/282970.aspx#282970
    @morbiuswilters said:


    It's nothing personal, I just despise xkcd. Let's step outside our little aspie corner of the Internet and consider: if there was a comic by an accountant and every strip was some hackneyed, unfunny joke about the obscure technicalities of tax law, we'd hate those people, right? We'd correctly identify them as social retards. We'd realize their "humor" was nothing but a defense mechanism against their social ineptitude; a desperate cry for help from people who had never touched a vagina.

    And it's not just the fact that xkcd is painfully unfunny garbage. For example, I really like Seinfeld but have you ever met someone who insists on drawing parallels between everything that happens to them and some episode of the show? "OMG, it was just like the time George..." Imagine what kind of monster would do something like that. That's what you are doing when you desperately cram xkcd down our throats at every opportunity. "Oh goodie, a post where somebody used the word 'random'; time for me to whip out old #221!" "SQL injection? Why, I bet these fair chaps have never been introduced to the comic stylings of Randall Munroe and his fabulous Bobby Tables character!"

    Worst of all, even if xkcd was funny (and I assure you, it's not) it doesn't make you funny to bring it up. Only in very rare, rare circumstances is it actually as funny or charming as you think it is to reference somebody else's joke; and then only because your new joke gave a different twist to the original. Humor is about the unexpected, not the banal. Repeating the same joke over and over again isn't unexpected, it's annoying.

    In real life you can stab the wayward Seinfeld fan in the eye with a fork (similar to Season 8, Episode 10 The Andrea Dorea where Elaine is dating the guy who keeps getting stabbed by women because he's a "bad breaker upper"). Unfortunately I am unable to stab you in the eye with a fork so I must rely on verbal attacks. I know it hurts but it's the only way the Internet will be cleansed. I know you understand.

    *Slow golf clap*


  • @jessicatian said:

    I can't understand

    Can't understand what?


  • Trolleybus Mechanic

    @Cassidy said:

    @Gazzonyx said:


    * <--- Joke
        _O_
     / /{ . }\ \ <--- Rosie
        / /\ \
    *WOOSH!*

    And a mod (that may or may not live in the shadows) may be along to Rosie his xkcd attempt before morb's cheek begins its nervous tic...

     

    rkcdtfy

     



  • @Lorne Kates said:

    @Cassidy said:

    @Gazzonyx said:


    • <--- Joke

          O
       / /{ . }\
      <--- Rosie
          / /\ <br>
      WOOSH!

    And a mod (that may or may not live in the shadows) may be along to Rosie his xkcd attempt before morb's cheek begins its nervous tic...

     

    rkcdtfy

     


    This makes me sad. :(

Log in to reply