[jbosscache-dev] create/drop for JDBCCacheLoader
Manik Surtani
manik at jboss.org
Mon Jul 6 07:27:44 EDT 2009
well the dummy table isn't really used for anything except as an
always-positive join target (you might call it a DB-independent
version of DUAL in Oracle). So I don't see any problems in dropping/
recreating, as in the case of the actual table that holds data.
But I see your point, for the sake of consistency. This code should
be moved into the condition along with the data table creation code.
Feel free to raise a JIRA/contribute a patch. :-)
On 6 Jul 2009, at 02:31, Andrew Duckworth wrote:
> Hi Everyone,
>
> I am using the JDBCacheLoader from JBoss Cache 3.0.3 and have
> noticed that setting the cache loader properties to prevent schema
> update to the DB are not working as expected. I have set
>
> cache.jdbc.table.create=false
> cache.jdbc.table.drop=false
>
> however if appears that the jbosscache_D table is dropped and
> recreated each time the cache loader starts. The relevant code is
> below, can anyone comment as to whether this behaviour is
> intentional, or should the
> createDummyTableIfNeeded method check for the table existence and
> avoid the drop/create ?
>
> Thanks in advance,
>
> Andrew
>
>
> public void start() throws Exception
> {
> cf.start();
>
> Connection con = null;
> Statement st = null;
>
> try
> {
> con = cf.getConnection();
> driverName = getDriverName(con);
> if (config.getCreateTable() && !
> tableExists(config.getTable(), con))
> {
> if (getLogger().isDebugEnabled())
> {
> getLogger().debug("executing ddl: " +
> config.getCreateTableDDL());
> }
> st = con.createStatement();
> st.executeUpdate(config.getCreateTableDDL());
> }
> }
> finally
> {
> safeClose(st);
> cf.close(con);
> }
>
> createDummyTableIfNeeded();
> }
>
> private void createDummyTableIfNeeded() throws Exception
> {
> Connection conn = null;
> PreparedStatement ps = null;
> try
> {
> conn = cf.getConnection();
> ps = prepareAndLogStatement(conn,
> config.getDummyTableRemovalDDL());
> ps.execute();
> }
> catch (Exception e)
> {
> if (getLogger().isTraceEnabled()) getLogger().trace("No need
> to drop tables!");
> }
> finally
> {
> safeClose(ps);
> cf.close(conn);
> }
>
> try
> {
> conn = cf.getConnection();
> ps = prepareAndLogStatement(conn,
> config.getDummyTableCreationDDL());
> ps.execute();
> safeClose(ps);
> ps = prepareAndLogStatement(conn,
> config.getDummyTablePopulationSql());
> ps.execute();
> }
> finally
> {
> safeClose(ps);
> cf.close(conn);
> }
> }
> _______________________________________________
> jbosscache-dev mailing list
> jbosscache-dev at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/jbosscache-dev
--
Manik Surtani
manik at jboss.org
Lead, Infinispan
Lead, JBoss Cache
http://www.infinispan.org
http://www.jbosscache.org
More information about the jbosscache-dev
mailing list