0

I have the following problem, in my REST server application (Jersey+ActiveJDBC+Shiro+TomcatJDBC) running in Tomcat 8 and database is PostgreSQL also it running in VPS.

Sometimes after large/many CRUD activity via REST application, the inserted data in database is not exist.

Note: I am using insert in ActiveJDBC since i have custom PK and not using any cache.

For example: via REST when calling total data it says 100, but when checking database directly it says 80. Then if i restart Tomcat, the REST will respond 80, thus the data is gone...

I already debug all potential error (Checked Tomcat Log, Postgresql Log, and App log, also the VPS) but found nothing! The inserted data it just like never inserted.

The data gone is happen sporadically, and I can't reproduce it. Thus I can't fix the bug.

(Edited, wrong reference before):

Then I found this Q&A : Hibernate not saving Object in the Database

Is there possibility ActiveJDBC have flush problem like above, since like Q&A above its only happen with PostgreSQL.

Saving Code :

try(DB db = new DB()){
        db.open(DataSourcePool.getInstance().ds_pooled);

        dbModel dbModel = new dbModel();
        dbModel.setPojoModel(PojoModel);

        CheckRulesCreate(dbModel);   // Business Rule Check, throw on Fail

        if (dbModel.insert())
            return Response.status(201).entity(new Outputs("OK",201,"Data saved!")).build();
    }

Data Source Pool :

//Singelton Based On Bill Pugh Singeltom Design
import org.apache.tomcat.jdbc.pool.DataSource;

DataSource ds = new DataSource();

ds.setDriverClassName("org.postgresql.Driver");
ds.setUrl("jdbc:postgresql://localhost/database");
ds.setUsername("blahblah");
ds.setPassword("hisshiss");

ds.setInitialSize(10);
ds.setMaxActive(300);
ds.setMinIdle(2);
ds.setValidationQuery("select 1");
ds.setTestOnBorrow(true);
ds.setRemoveAbandoned(true);
ds.setRemoveAbandonedTimeout(60);
ds.setMaxWait(10000);
ds.setName("DataSourcePool");
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Heykal
  • 1
  • 1

1 Answers1

0

ActiveJDBC is not like that. If you experience an issue like that chances are you have a bug in your code.

In any case, ActiveJDBC is a Pass-Through framework: The moment you call any of the CRUD methods, the framework calls underlying JDBC. One exception are Batch operations, but that will be intentional.

If your app was working for a year and had no issues, and now you do have issues, you need to see what changed.

ipolevoy
  • 5,432
  • 2
  • 31
  • 46
  • For note last year when application first launch there no any problem, the application works as intended. Then suddenly the data disappeared (but not old data, just recently inserted data sometime between 1-3 days range also not all new inserted data, just some of it) – Heykal May 25 '18 at 05:51
  • sorry, but your code is very obscure. I added to the answer. – ipolevoy May 25 '18 at 16:54