0

I'm working on a java application that create and store invoice in pdf. I create a new folder for every new year an every new month I stored it as follow:

 private void CreateDir () {

    Calendar now = Calendar.getInstance();
    int year = now.get(Calendar.YEAR);
    String yearInString = String.valueOf(year);


    int month = now.get(Calendar.MONTH) +1;
    String monthInYear = String.valueOf(month);


    File rootDir = File.listRoots()[0];
    File dir = new File(new File(new File(rootDir, "MijnFacturen"), yearInString), monthInYear);
    if (!dir.exists()){
        dir.mkdirs();
        System.out.println("directories made");
        setInvoicePath(dir.toString());
        System.out.println(invoicePath);
    } else {
        setInvoicePath(dir.toString());
        System.out.println(invoicePath);
    }

}

So for so good. But when i save the path to mysql database it automatically removes the backslashes from my string. I read that it was a bad practical to save paths in a database. But where should i save my pathfile then. And whats the best way to retrieve it ??

1 Answer 1

1

Why not save the invoices directly into the database as BLOBs? It'll be a lot more convenient and you can query them easily by any metadata (dates, total values, etc.) that you store with them.

Sign up to request clarification or add additional context in comments.

2 Comments

Can you give my a quick explanations how blobs work. We only have seen some lessons of sql and never talk about blobs ? Do you now any good websites with some examples ?
It's a binary column in the database. Essentially the same as if you'd store it in file yourself, except more robust and you don't need to worry about paths. Plenty of tutorials and info available at your favourite search engine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.