Menu

org.hsqldb.HsqlException: The table data is read only

Help
HyeRin
2018-10-17
2019-05-03
  • HyeRin

    HyeRin - 2018-10-17

    Originally I used ojdbc for MS access DB.
    But as you know, nowdays, we have to change oracle JDK to open JDK.
    So I changed Java 1.7 to zulu openJDK 8.
    And then I can't use ojdbc anymore.

    I searched solution and found UCanAccess.

    First of all, I added dependency UCanAccess to maven.
    Then I got ucanaccess-4.0.4.jar, hsqldb-2.3.1.jar, jackcess-2.1.11.jar.

    Second, I updated applicationContext.xml

     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
            <property name="driverClassName" value="net.ucanaccess.jdbc.UcanaccessDriver" />
            <property name="url" value="jdbc:ucanaccess://D:/ncdb.mdb" />
            <property name="username" value="sa" />
            <property name="password" value="password" />
        </bean>
    

    Finally I ran tomcat service.
    But It didn't work correctly, and the following errors appeared.

    org.springframework.jdbc.UncategorizedSQLException: StatementCallback; uncategorized SQLException for SQL [ALTER TABLE NC_OPTION ADD COLUMN admin_access_ips MEMO NOT NULL DEFAULT '']; SQL state [null]; error code [0]; UCAExc:::4.0.4 java.sql.SQLException: The table data is read only in statement [ALTER TABLE NC_OPTION ADD COLUMN admin_access_ips  LONGVARCHAR]; nested exception is net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::4.0.4 java.sql.SQLException: The table data is read only in statement [ALTER TABLE NC_OPTION ADD COLUMN admin_access_ips  LONGVARCHAR]
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:83)
        at org.springframework.jdbc.support.AbstractFallbackSQLExceptionTranslator.translate(AbstractFallbackSQLExceptionTranslator.java:80)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:407)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:428)
        at kr.doctorsoft.netclinic.service.NetclinicTable.addColumnAdminAccessIps(NetclinicTable.java:533)
        at kr.doctorsoft.netclinic.web.context.NetClinicContextListener.updateDatabase(NetClinicContextListener.java:137)
        at kr.doctorsoft.netclinic.web.context.NetClinicContextListener.contextInitialized(NetClinicContextListener.java:35)
        at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:5077)
        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5591)
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
        at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
    Caused by: net.ucanaccess.jdbc.UcanaccessSQLException: UCAExc:::4.0.4 java.sql.SQLException: The table data is read only in statement [ALTER TABLE NC_OPTION ADD COLUMN admin_access_ips  LONGVARCHAR]
        at net.ucanaccess.jdbc.UcanaccessStatement.execute(UcanaccessStatement.java:159)
        at org.apache.commons.dbcp.DelegatingStatement.execute(DelegatingStatement.java:264)
        at org.apache.commons.dbcp.DelegatingStatement.execute(DelegatingStatement.java:264)
        at org.springframework.jdbc.core.JdbcTemplate$1ExecuteStatementCallback.doInStatement(JdbcTemplate.java:421)
        at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:396)
        ... 13 more
    Caused by: java.sql.SQLException: java.sql.SQLException: The table data is read only in statement [ALTER TABLE NC_OPTION ADD COLUMN admin_access_ips  LONGVARCHAR]
        at net.ucanaccess.jdbc.AbstractExecute.addDDLCommand(AbstractExecute.java:240)
        at net.ucanaccess.jdbc.AbstractExecute.executeBase(AbstractExecute.java:261)
        at net.ucanaccess.jdbc.Execute.execute(Execute.java:44)
        at net.ucanaccess.jdbc.UcanaccessStatement.execute(UcanaccessStatement.java:157)
        ... 17 more
    Caused by: java.sql.SQLException: The table data is read only in statement [ALTER TABLE NC_OPTION ADD COLUMN admin_access_ips  LONGVARCHAR]
        at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
        at org.hsqldb.jdbc.JDBCUtil.sqlException(Unknown Source)
        at org.hsqldb.jdbc.JDBCStatement.fetchResult(Unknown Source)
        at org.hsqldb.jdbc.JDBCStatement.execute(Unknown Source)
        at net.ucanaccess.jdbc.AbstractExecute.addDDLCommand(AbstractExecute.java:234)
        ... 20 more
    Caused by: org.hsqldb.HsqlException: The table data is read only
        at org.hsqldb.error.Error.error(Unknown Source)
        at org.hsqldb.error.Error.error(Unknown Source)
        at org.hsqldb.TableWorks.checkModifyTable(Unknown Source)
        at org.hsqldb.TableWorks.checkAddColumn(Unknown Source)
        at org.hsqldb.TableWorks.addColumn(Unknown Source)
        at org.hsqldb.StatementSchema.getResult(Unknown Source)
        at org.hsqldb.StatementSchema.execute(Unknown Source)
        at org.hsqldb.Session.executeCompiledStatement(Unknown Source)
        at org.hsqldb.Session.executeDirectStatement(Unknown Source)
        at org.hsqldb.Session.execute(Unknown Source)
        ... 23 more
    

    This is the code of where the error occurred.

    jdbcTemplate.execute("ALTER TABLE NC_OPTION ADD COLUMN admin_access_ips MEMO NOT NULL DEFAULT ''");
    'jdbcTemplate ' is org.springframework.jdbc.core.JdbcTemplate.

    When I run mybatis 's (mapper.xml) insert or update, these messages are appeared too.
    Why the table is setted 'read-only' ?
    How can I remove read-only property?

     
  • Gord Thompson

    Gord Thompson - 2019-05-03

    Is the .mdb file in Access_97 format?

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.