It sounds to me like hiding the Check button (and having a pre-check for sanity's sake) would fit the bill. This would mean students could use pre-check for syntax errors (or whatever else you let pre-check check) but their code wouldn't be run against any test cases until they submit their quiz, or the quiz closes.
Another option is only running very basic tests during the quiz, and then loading the more complex test cases later, and doing a re-grade. We do that in some of our courses when we want students to have an idea if they're failing very basic test cases, but not if they're failing edge ones. This does have the downside of students believing they have a higher mark than they actually do at the end.
If you really want to disable the check button, I've done something similar, but only in a customised Python question type, I do not know if it transfers to JDBC. The Twig variable QUESTION (mentioned here under the heading "The Twig Question Variable"
https://github.com/trampgeek/moodle-qtype_coderunner) has a field called stepinfo. This in turn has the attribute numchecks. Using a combinator grader template, you can check if numchecks is greater than your threshold, and if so set the outcome json's prologue equal to a bit of JavaScript that disables to Check button.
My implementation looked like:
params['STEP_INFO'] = json.loads(r"""{{ QUESTION.stepinfo | json_encode }}""")
self.num_checks = params["STEP_INFO"]["numchecks"]
if self.num_checks == 2 and self.params['forassessment']:
prologue = ""
outcome[prologuehtml] = prologue
Which stopped students after 3 checks. I'm not entirely sure if this option would work, but thought I'd put it into the world!
(I personally think option 1 or 2 are far nicer and cleaner, we had to implement option 3 as high school students absolutely love repeatedly clicking check even after getting a 100% penalty).