Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Externalize SQL queries #2

Open
LlemonDuck opened this issue Jul 15, 2022 · 0 comments
Open

Externalize SQL queries #2

LlemonDuck opened this issue Jul 15, 2022 · 0 comments

Comments

@LlemonDuck
Copy link
Contributor

Port of runelite/runelite#8740

Perhaps a rather minor thing, but I only mention it because code is otherwise very clean.

SQL queries (e.g. https://github.com/runelite/runelite/blob/master/http-service/src/main/java/net/runelite/http/service/loottracker/LootTrackerService.java) can be moved into xml file inside src/main/resources, and then read using standard java properties.

E.g.: src/main/resources/sql/loottracker.sql:

<properties>
    <entry key="createTable">
    <![CDATA[
        CREATE TABLE ....
    ]]>
    </entry>
</properties>

and then inside service file:

Properties sqlProperties = new Properties();
sqlProperties.loadFromXML(new ClassPathResource("sql/loottracker.sql").getInputStream());
String createTableQuery = sqlProperties.getProperty("createTable");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant