How to print a file on a scheduled date? [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am working on printing a file with scheduled date (selected a date from datepicker) in Java, but I don't have any idea about how to do it.

Use cron based tasks that will fire and do the work. For your case, you may use Quartz

It's depend on what actualy you do.
If you want to print many files in different time (printer queque in some oraginsation for example) you could follow next recomendation:
1) place all records about planned print in some storage (file, DB)
2) create one scheduler( #Scheduled in spring for example, or java sheduled executor) wich will processed queqe every minute(if minute is minmal interval of date that you could select).
(Be careful and select delay option instead of rate in your scheduler)
3) print only whose files that time to proceed.

Related

How can I limit the user to add only one item to a ResycleView per day in kotlin [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed last year.
Improve this question
is there a way to make the user add just one item per day, then get an alert saying "only one time a day"
what to use, coroutine, tasktimer, work manger ?
I will try and give a general answer.
Usually when it comes to such requirements it is good to compare the date and time of the last item that was created and the current date and time. That means you would need to store the item in a database.
The reason I'm suggesting such an approach is because a user might close your app, or the OS might put it to sleep / terminate it and all of your tasks and timers might be stopped. By having it persisted in a DB, you can always be sure your requirements are met.
For example if the requirement is 24 hours or perhaps just a calendar day (after midnight), then you would do the comparison and know if they have been met and allow the creation of new items, or not.
Additionally, it's always good to try and experiment at first. See what works and what doesn't before asking your question.
Good luck.

Import large csv files spring [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I have not used Spring Batch so far and i was wondering if this is maybe the time to break the ice.
I have large csv files with 10k to 30k lines that i need to import into database. Also i would need to do some processing of that data. Like checking some fields if they exist in the db (if not the row should be ignored). I never used Spring Batch so i would need to spend some time getting to know it so i can use it. But also i have a really strict deadline for this.
But is it really worth it for this kind of work? Since it would not be something like scheduled job witch would be done on daily, weekly or monthly basis. It would be done per need. Maybe once in a few months.
So is it "overkill" to use batch processing or it would be fine to just iterate line by line with some buffered reader?
If it is a one-off job for "just" 10k-20k lines, Spring Batch is complete overkill and you are better of writing something smaller, yourself.

What is the most efficient way to use database? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm new to using a database, specifically MySQL. I'm creating a web application for class in which you can look up the name of a book and it'll display the summary of the book. My question is should I send a query to the database that collects all of the books' data on initialization and put them into a HashMap inside a manager class for lookup or should I use a query each time to lookup a specific book information?
It depends on the data transport time I would say. If your average query time times the number of request goes faster than a script to put everything into a HashMap, use queries. Otherwise, use a script that collects everything and puts it into a HashMap.
But if you have thousands of rows, you should use queries, because otherwise you will use too much RAM.

make a GET call 100,000 times [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have a requirement where I am writing a small utility to test apis(ofcourse there are existing tools but it has been decided to write one). I am required to bombard the api, for the same api call, with say 100 threads, around say 100,000 times.
I am using 'PoolingHttpClientConnectionManager' for the making the calls. I am using something as mentioned in the below link:
https://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html
My question is:
(1) How can I run the above code for 100,000 iterations? Using that many number of threads is obviously a bad idea. Initially thought of using ExecutorService for maintaining thread count and number of jobs to be submitted but it felt redundant.
(2)I read about 'setMaxTotal'(max connections) and 'setDefaultMaxPerRoute'(concurrent connections) but I dont think it will help achieve(1) though I will obviously be required to increase the values.
Please advise. Thanks in advance.
You could use a threadpool and push the workerfunction the required number of times. Then you could even vary the number of workerthreads executing the functions to simulate different loadsituations.
Threadpool tutorial:
https://docs.oracle.com/javase/tutorial/essential/concurrency/pools.html
Why don't you use Jmeter for such performance/load testing?

How to set a restriction for each phone/user on my app? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm starting to build an app where people vote certain stuff just by clicking on happy/sad faces (kind of like grading it). The thing is that I dont want to make a log-in nor registration for my app (the reason is a long story). So is there any way that I can limit people's vote to 2 per day? Every phone/user could only vote twice a day, and that count will reset after 24h from the first vote.
You have tow options:
Limit the number of votes on the device, by saving the number of votes into persistant storage on the device with a timestamp and act accordingly.
Or (more secure, but also more difficult)
Track the installations as described here identifying app installation
And send the id with every request and validate on the server side.

Categories