[jbosscache-dev] create/drop for JDBCCacheLoader
Andrew Duckworth
Andrew.Duckworth at sandstone.com.au
Sun Jul 5 21:31:29 EDT 2009
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);
}
}
More information about the jbosscache-dev
mailing list