What is the correct way of running a session formatting query via ORMLite? The reason that I am setting session formatting is that the queries that I run never retrieve any results and I keep getting an absurd error (you can see it below).
This is what I am currently doing to set up the session format:
String sqlSession = "alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS';";
Conn.My_Dao().queryRaw(sqlSession);
But I keep getting the following error:
java.sql.SQLException: Could not perform raw query for
alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS';
The reason I am doing that (as I mentioned earlier) - is that for any query that I run I get the following error:
java.sql.SQLException: Problems parsing default date string '2021-01-01 00:00:00'
using 'yyyy-MM-dd HH:mm:ss.SSSSSS'
I had experienced something similar with Oracle SQL in the past (with an old PHP project to be precise) and I just handled it by setting the session formating to the aforementioned one.
However, I agree that this might not be the most elegant solution to this problem. What would the best way to handle it?
In the future, make sure to post more of the exception when you get one. I suspect that there was a "Caused by" line later on in the exception that said something about this not being a query.
I'm guessing that you should use the
Dao.executeRaw(...)method instead ofDao.queryRaw(...). Queries really need to beselectstatements which return results.