Finding out which line of code throws an SQL exception

I have an Actor (Play Framework, Java) for regularly importing database data. This actor calls various other classes that perform import, persist, etc. My current problem is that I cannot determine the exact line number and file that generates SQL exceptions. For example, I get errors like this:

[info] application - javax.persistence.PersistenceException: ERROR executing DML bindLog[] error[ERROR: null value in column "email" violates not-null constraint\n   Detail: Failing row contains (266, null, null, null).]
[info] application - Starting persisting of customer id 29917837
[error] o.j.StatementLogger - insert into emails (email, domain, user_id) values (null,null,null);
throws exception: org.postgresql.util.PSQLException: ERROR: null value in column "email" violates not-null constraint
  Detail: Failing row contains (268, null, null, null).
org.postgresql.util.PSQLException: ERROR: null value in column "email" violates not-null constraint
  Detail: Failing row contains (268, null, null, null).
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2182)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1911)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:173)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:645)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:495)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:441)
    at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61)
    at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java)
    at sun.reflect.GeneratedMethodAccessor16.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

Naturally, I can see the error message and see that something is trying to save my email model somewhere without filling it. Now the code base is very small (~ 200-300 lines), and I can guess exactly where it comes from. But should frames not report line numbers? Or perhaps this is what happens when the actors are used because they are somehow outside the system and everything?

+4
1

, , . , , , , , .

, , , , "" , , . , .

, :

try {
     this.custPersister.persist(customer);
} catch (Exception e) {
     throw new Exception(e);
}

, , .

+4

Source: https://habr.com/ru/post/1663669/


All Articles