java - How can I use SQLite in Quartz? -


i'm trying use quartz sqlite in application . when read documentation here notice didn't mention sqlite among databases available. say:

jdbcjobstore works database, has been used oracle, postgresql, mysql, ms sqlserver, hsqldb, , db2. use jdbcjobstore, must first create set of database tables quartz use. can find table-creation sql scripts in “docs/dbtables” directory of quartz distribution.

so, question: which setup script use setting quartz sqlite table? use derby script applied sqlite script.

the problem when trying schedule trigger in previous inserted job. part of code:

// , start off scheduler.start();  map<string, string> map = new hashmap<>(); map.put("key", "value");  jobdatamap jdm = new jobdatamap(map);  jobkey key = new jobkey("job1", "key1");   if(!scheduler.checkexists(key)){      jobdetail job = newjob(hellojob.class).withidentity(key).storedurably().usingjobdata(jdm).build();      addjob(scheduler, job);       // trigger job run now, , repeat every 40 seconds     trigger trigger = newtrigger()          .withidentity("trigger1", "group1")          .startnow()             .forjob(job)                .withschedule(simpleschedule()                  .withintervalinseconds(40)                  .repeatforever())                      .build();      // tell quartz schedule job using our trigger     scheduler.schedulejob(trigger); // here error  }  thread.sleep(60000);  scheduler.shutdown(); 

my quartz.properties this:

org.quartz.scheduler.instancename = myscheduler org.quartz.threadpool.threadcount = 5 org.quartz.jobstore.class = org.quartz.impl.jdbcjobstore.jobstoretx org.quartz.jobstore.tableprefix = qrtz_ org.quartz.datasource.sqlitedb.driver = org.sqlite.jdbc org.quartz.datasource.sqlitedb.url = jdbc:sqlite:bota.db org.quartz.datasource.sqlitedb.maxconnections = 30 org.quartz.jobstore.driverdelegateclass = org.quartz.impl.jdbcjobstore.stdjdbcdelegate org.quartz.jobstore.datasource = sqlitedb 

i'm using sqlite v-3.8.11.2 , quartz v-2.2.2. in log:

org.quartz.jobpersistenceexception: couldn't store trigger 'group1.trigger1' 'key1.job1' job:couldn't retrieve job: not implemented sqlite jdbc driver [see nested exception: org.quartz.jobpersistenceexception: couldn't retrieve job: not implemented sqlite jdbc driver [see nested exception: java.sql.sqlexception: not implemented sqlite jdbc driver]]     @ org.quartz.impl.jdbcjobstore.jobstoresupport.storetrigger(jobstoresupport.java:1223)     @ org.quartz.impl.jdbcjobstore.jobstoresupport$4.executevoid(jobstoresupport.java:1159)     @ org.quartz.impl.jdbcjobstore.jobstoresupport$voidtransactioncallback.execute(jobstoresupport.java:3715)     @ org.quartz.impl.jdbcjobstore.jobstoresupport$voidtransactioncallback.execute(jobstoresupport.java:3713)     @ org.quartz.impl.jdbcjobstore.jobstoresupport.executeinnonmanagedtxlock(jobstoresupport.java:3799)     @ org.quartz.impl.jdbcjobstore.jobstoretx.executeinlock(jobstoretx.java:93)     @ org.quartz.impl.jdbcjobstore.jobstoresupport.storetrigger(jobstoresupport.java:1155)     @ org.quartz.core.quartzscheduler.schedulejob(quartzscheduler.java:932)     @ org.quartz.impl.stdscheduler.schedulejob(stdscheduler.java:258)     @ javaapplication2.javaapplication2.main(javaapplication2.java:174) caused by: org.quartz.jobpersistenceexception: couldn't retrieve job: not implemented sqlite jdbc driver [see nested exception: java.sql.sqlexception: not implemented sqlite jdbc driver]     @ org.quartz.impl.jdbcjobstore.jobstoresupport.retrievejob(jobstoresupport.java:1396)     @ org.quartz.impl.jdbcjobstore.jobstoresupport.storetrigger(jobstoresupport.java:1205)     ... 9 more caused by: java.sql.sqlexception: not implemented sqlite jdbc driver     @ org.sqlite.jdbc4.jdbc4resultset.unused(jdbc4resultset.java:320)     @ org.sqlite.jdbc4.jdbc4resultset.getblob(jdbc4resultset.java:345)     @ com.mchange.v2.c3p0.impl.newproxyresultset.getblob(newproxyresultset.java:285)     @ org.quartz.impl.jdbcjobstore.stdjdbcdelegate.getobjectfromblob(stdjdbcdelegate.java:3190)     @ org.quartz.impl.jdbcjobstore.stdjdbcdelegate.selectjobdetail(stdjdbcdelegate.java:860)     @ org.quartz.impl.jdbcjobstore.jobstoresupport.retrievejob(jobstoresupport.java:1385)     ... 10 more build stopped (total time: 11 seconds) 

the problem seems sqlite jdbc driver does not support method resultset.getblob().

but quartz uses method retrieve jobdatamap assigned job.

if still want use quartz sqlite extend stdjdbcdelegate , retrieve/set blobs suggested in answer.

at first glance seems must override methods

  1. stdjdbcdelegate.getobjectfromblob() and
  2. stdjdbcdelegate.getjobdatafromblob()

since i'm not sure wether later come more problems ( example see sqlite jdbcdriver has lot more unsupported resultset methods ) rather recommend use database works out-of the-box.


Comments

Popular posts from this blog

Django REST Framework perform_create: You cannot call `.save()` after accessing `serializer.data` -

Why does Go error when trying to marshal this JSON? -