Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 155619
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T10:11:15+00:00 2026-05-11T10:11:15+00:00

I have a Java project which will include a number of large SQL statements

  • 0

I have a Java project which will include a number of large SQL statements for querying the database. My question is: where should I store them?

I’m fairly sure I want each statement its own text file managed by source code control. As Java doesn’t support multi-line strings I can’t easily put the SQL in my .java files and I don’t think I’d want to anyway. At build time I can put these text files in JAR and get the contents with ClassLoader.getResourceAsStream().

So my problem becomes in which directories should I put these files and what should I call them. Ideally I’d like people to tell from the .sql file which Java class uses it. What I definitely don’t want is a single directory full of lots of files called things like report1.sql and report3.sql and so on.

My inclination is to put them in the package directory with all the .java files but I have a colleague who doesn’t like having anything other than .java files in this tree. So this leads to alternative of a separate directory structure which mirrors the Java packages but this seems like an unnecessary overhead.

So I would be interested to hear what you do with your SQL files.

We’re using Netbeans 6.5 in case that will affect your answers.

(This question is similar but sadly the answers are very C# specific, which is good for that question but bad for me.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T10:11:15+00:00Added an answer on May 11, 2026 at 10:11 am

    In a Java/Maven setting we use as project hierarchy:

    project/src/main/java/Package/Class.java project/src/test/java/Package/ClassTest.java project/src/main/resources/Package/resource.properties project/src/test/resources/Package/test_resource.properties 

    And in order to answer your question: I would put the SQL-files along with the resources under src/main/resources.

    You may want to have a look at this thread.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 187k
  • Answers 187k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If by "contain a flash" you mean the page you're… May 12, 2026 at 5:19 pm
  • Editorial Team
    Editorial Team added an answer You shouldn't use sed like that. As your script now… May 12, 2026 at 5:19 pm
  • Editorial Team
    Editorial Team added an answer CampaignService AdGroupService AdGroupAdServie May 12, 2026 at 5:19 pm

Related Questions

I'm getting the LNK2005: already defined in (...) error when building my project in
I have a very simple problem. I have an application which is written in
i have written a java program which currently runs as a desktop app, it
I am using Eclipse 3.4.2 to develop my code. As part of my project

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.