Ah I see. So When we are executing
JDBC it actually runs the JPQL as SQL inside the database. Therefore, when you are selecting LOT_ID into MyLot, you are only creating the variable on the Oracle Database and not in the JVM. As a solution, you can create the variable MyLot in java and then place it in your JPQL Statement by using the result set from the first statement and assigning it to that variable you created. Alternatively, you might be able to call the variable you create in the Oracle DB just like you would as a regular SQL statement, although I have not tried this with JDBC so I'm not 100% sure it will work.
as a note, JPQL stands for Java Persistence Query Language and is just the how you have written the SQL in java.
Hopefully that helps.
-Zach