Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 16, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 16, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 16, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 16, 2025

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025

      Minecraft licensing robbed us of this controversial NFL schedule release video

      May 16, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The power of generators

      May 16, 2025
      Recent

      The power of generators

      May 16, 2025

      Simplify Factory Associations with Laravel’s UseFactory Attribute

      May 16, 2025

      This Week in Laravel: React Native, PhpStorm Junie, and more

      May 16, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025
      Recent

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»CodeSOD: A Matter of Understanding

    CodeSOD: A Matter of Understanding

    November 4, 2024

    For years, Victoria had a co-worker who “programmed by Google Search”; they didn’t understand how anything worked, they simply plugged their problem into Google search and then copy/pasted and edited until they got code that worked. For this developer, I’m sure ChatGPT has been a godsend, but this code predates its wide use. It’s pure “Googlesauce”.

        StringBuffer stringBuffer = new StringBuffer();
        stringBuffer.append("SELECT * FROM TABLE1 WHERE COLUMN1 = 1 WITH UR");
    
        String sqlStr = stringBuffer.toString();
        ps = getConnection().prepareStatement(sqlStr);
    
        ps.setInt(1, code);
    
        rs = ps.executeQuery();
    
        while (rs.next())
        {
          count++;
        }
    

    The core of this WTF isn’t anything special- instead of running a SELECT COUNT they run a SELECT and then loop over the results to get the count. But it’s all the little details in here which make it fun.

    They start by using a StringBuffer to construct their query- not a horrible plan when the query is long, but this is just a single, simple, one-line query. The query contains a WITH clause, but it’s in the wrong spot. Then they prepareStatement it, which does nothing, since this query doesn’t contain any parameters (and also, isn’t syntactically valid). Once it’s prepared, they set the non-existent parameter 1 to a value- this operation will throw an exception because there are no parameters in the query.

    Finally, they loop across the results to count.

    The real WTF is that this code ended up in the code base, somehow. The developer said, “Yes, this seems good, I’ll check in this non-functional blob that I definitely don’t understand,” and then there were no protections in place to keep that from happening. Now it falls to more competent developers, like Victoria, to clean up after this co-worker.

    [Advertisement]
    Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!

    Source: Read More 

    Hostinger
    Facebook Twitter Reddit Email Copy Link
    Previous ArticleLLaMA-Berry: Elevating AI Mathematical Reasoning through a Synergistic Approach of Monte Carlo Tree Search and Enhanced Solution Evaluation Models
    Next Article pEBR: A Novel Probabilistic Embedding based Retrieval Model to Address the Challenges of Insufficient Retrieval for Head Queries and Irrelevant Retrieval for Tail Queries

    Related Posts

    Machine Learning

    Salesforce AI Releases BLIP3-o: A Fully Open-Source Unified Multimodal Model Built with CLIP Embeddings and Flow Matching for Image Understanding and Generation

    May 16, 2025
    Security

    Nmap 7.96 Launches with Lightning-Fast DNS and 612 Scripts

    May 16, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Meet LLMSA: A Compositional Neuro-Symbolic Approach for Compilation-Free, Customizable Static Analysis with Reduced Hallucinations

    Development

    Podcastle Review: Can It Simplify Podcast Production?

    Development

    Pay Once and Use This PDF Tool Forever

    Development

    Critical Erlang/OTP SSH RCE bug now has public exploits, patch now

    Security

    Highlights

    Why Attractive Design Can Mask Usability Flaws

    August 10, 2024

    Users often perceive aesthetically pleasing design as design that’s more usable. Source: Read More 

    Parallels Desktop 20.3 Brings Linux VM Fixes to Mac Users

    Parallels Desktop 20.3 Brings Linux VM Fixes to Mac Users

    April 19, 2025

    CVE-2025-3820 – Tenda W12 and i24 Remote Stack-Based Buffer Overflow

    April 23, 2025

    Laravel 11 CRUD Operation

    May 4, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.