Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Log4j - JDBCLogger::setLogType() throws a column is not writable message

 
Priyaa V Kumar
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to use the JDBCAppender provided in the package org.apache.log4j.jdbcplus to write to multiple columns of a particular table.

I get a java class enclosing some integer and string members. I want these values to go into different columns of a table.

My program has the following code snippet

// Create a new instance of JDBCAppender
JDBCAppender ja = new JDBCAppender();
ja.setUrl("jdbc dbc:test");
ja.setUsername("Admin");
ja.setPassword("");
ja.setTable("result");

ResultObject rslt = null; //my java class with some ints & strings

for (int i = 0; i < 1; i++)
{
rslt = new ResultObject();

rslt.setCol1(1);
rslt.setCol2(1);
rslt.setCol3(20);
rslt.setName("Actual name " + i);

ja.setColumn("Col1", JDBCLogType.EMPTY, "" + rslt.getCol1());
ja.setColumn("Col2", JDBCLogType.EMPTY, "" + rslt.getCol2());
ja.setColumn("Col3", JDBCLogType.EMPTY, "" + rslt.getCol3());

ja.setColumn("Name", JDBCLogType.MSG, "" +rslt.getName());

logger.info(rslt);
}


..........
..........


I get the message/error

log4j:ERROR JDBCAppender::configure()
java.lang.Exception: JDBCLogger::setLogType(), Column COL1 is not writeable !
at org.apache.log4j.jdbcplus.JDBCLogger.setLogType(JDBCLogger.java:212)
at org.apache.log4j.jdbcplus.JDBCAppender.configure(JDBCAppender.java:98
9)
at org.apache.log4j.jdbcplus.JDBCAppender.ready(JDBCAppender.java:880)
at org.apache.log4j.jdbcplus.JDBCAppender.append(JDBCAppender.java:816)
at org.apache.log4j.AppenderSkeleton.doAppend(AppenderSkeleton.java:221)

Is the database readonly? Using this same user id & password, I was able to write to this table using a simple java.sql.Statement?

Please let me know if I am missing something here...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic