Problem in JDBC cache loader
sridhar_ratna Feb 5, 2009 11:23 PMI have written a small program to load the database contents into jboss cache.
public class Test { public static void main(String[] args) { //JDBCCacheLoader init Properties props = new Properties(); props.put("cache.jdbc.table.name","jbosscache"); props.put("cache.jdbc.table.create","false"); props.put("cache.jdbc.fqn.column","fqn"); props.put("cache.jdbc.node.column","value"); props.put("cache.jdbc.driver","com.mysql.jdbc.Driver"); props.put("cache.jdbc.url","jdbc:mysql://172.16.16.42:3306/jbosscache"); props.put("cache.jdbc.user","root"); props.put("cache.jdbc.password","root"); props.put("cache.jdbc.parent.column","null"); CacheLoaderConfig.IndividualCacheLoaderConfig config = new CacheLoaderConfig.IndividualCacheLoaderConfig(); config.setProperties(props); JDBCCacheLoader jdbcCacheLoader = null; jdbcCacheLoader = new JDBCCacheLoader(); jdbcCacheLoader.setConfig(config); try { jdbcCacheLoader.start(); } catch (Exception e) { e.printStackTrace(); } }
I am using the MySQL database and the table structure is
CREATE TABLE `jbosscache`.`jbosscache` ( `jbosscache_pk` int(10) unsigned NOT NULL auto_increment, `fqn` varchar(255) NOT NULL default '', `value` longblob NOT NULL, PRIMARY KEY (`jbosscache_pk`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
When i run the program it is giving the following error.
log4j:WARN No appenders could be found for logger (org.jboss.cache.loader.JDBCCacheLoaderConfig). log4j:WARN Please initialize the log4j system properly. java.lang.IllegalStateException: Failed to insert node: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null) SELECT '/', null, null FROM jbosscache_D WHERE NOT EXISTS (SELECT fqn FROM' at line 1 at org.jboss.cache.loader.AdjListJDBCCacheLoader.insertNode(AdjListJDBCCacheLoader.java:540) at org.jboss.cache.loader.JDBCCacheLoader.addNewSubtree(JDBCCacheLoader.java:348) at org.jboss.cache.loader.JDBCCacheLoader.put(JDBCCacheLoader.java:145) at org.jboss.cache.loader.JDBCCacheLoader.start(JDBCCacheLoader.java:380) at Test.main(Test.java:63) Caused by: com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'null) SELECT '/', null, null FROM jbosscache_D WHERE NOT EXISTS (SELECT fqn FROM' at line 1 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723) at com.mysql.jdbc.Connection.execSQL(Connection.java:3283) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1332) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1604) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1519) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1504) at org.jboss.cache.loader.AdjListJDBCCacheLoader.insertNode(AdjListJDBCCacheLoader.java:527) ... 4 more
What might be the problem. Can anybody help me to solve the problem.
Thanks in advance