@Autowired private DSLContext create;
public boolean myMethod(String fieldOne, int fieldTwo) {
String fieldThree = getFieldThree();
try { MyTablePojo newPojo = new MyTablePojo(); //This is an auto generated pojo
newPojo.setFieldOne(fieldOne); newPojo.setFieldTwo(fieldTwo); newPojo.setFieldThree(fieldThree);
MyTableRecord newRecord = create.newRecord(MY_TABLE, newPojo); newRecord.insert(); return true; } catch (Exception e) { log.log(Level.WARNING, "ERROR Occurred", e); return false; }
}org.jooq.exception.DataAccessException: SQL [insert into `MyDatabase`.`MyTable` (`field_one`, `field_two`, `field_three`) values (?, ?, ?)]; Connection is read-only. Queries leading to data modification are not allowed at org.jooq.impl.Utils.translate(Utils.java:1690) at org.jooq.impl.DefaultExecuteContext.sqlException(DefaultExecuteContext.java:660) at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:356) at org.jooq.impl.TableRecordImpl.storeInsert0(TableRecordImpl.java:177) at org.jooq.impl.TableRecordImpl$1.operate(TableRecordImpl.java:143) at org.jooq.impl.RecordDelegate.operate(RecordDelegate.java:128) at org.jooq.impl.TableRecordImpl.storeInsert(TableRecordImpl.java:139) at org.jooq.impl.TableRecordImpl.insert(TableRecordImpl.java:132) at org.jooq.impl.TableRecordImpl.insert(TableRecordImpl.java:127)
... [Redacted] at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)Caused by: java.sql.SQLException: Connection is read-only. Queries leading to data modification are not allowed at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1055) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956) at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:926) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1970) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1937) at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1922) at org.jooq.tools.jdbc.DefaultPreparedStatement.executeUpdate(DefaultPreparedStatement.java:88) at org.jooq.impl.AbstractDMLQuery.execute(AbstractDMLQuery.java:349) at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:342) ... 18 more MyPoJo newPojo = new MyPoJo(); newPojo.setFeildOne(fieldOne); newPojo.setFieldTwo(fieldTwo); newPojo.setFieldThree(fieldThree); MyRecord newRecord = create.newRecord(MY_TABLE, newPojo); newRecord.insert();org.jooq.exception.DataAccessException: SQL [insert into `Database`.`MyTable` (`field_one`, `field_two`, `field_three`) values (?, ?, ?)]; Connection is read-only. Queries leading to data modification are not allowedHi Tim,
do you use immutable pojos?
<!-- Generate immutable POJOs for usage of the ResultQuery.fetchInto(Class) API
This overrides any value set in <pojos/>
Defaults to false -->
<immutablePojos>false</immutablePojos>
Cheers> 17) at java.lang.Thread.run(Thread.java:745)
Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection(url, username, password); DSLContext create = DSL.using(conn); <tx:annotation-driven transaction-manager="transactionManager"/>
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <property name="dataSource" ref="dataSource" /> </bean>
<!-- Configure jOOQ's ConnectionProvider to use Spring's TransactionAwareDataSourceProxy, which can dynamically discover the transaction context --> <bean id="transactionAwareDataSource" class="org.springframework.jdbc.datasource.TransactionAwareDataSourceProxy"> <constructor-arg ref="dataSource" /> </bean>
<bean class="org.jooq.impl.DataSourceConnectionProvider" name="connectionProvider"> <constructor-arg ref="transactionAwareDataSource" /> </bean> @Bean(name = "dataSource") public DataSource getDataSource() {
//Internal configuration object DataAccessConfiguration dataAccessConfiguration = new DataAccessConfiguration();
try { Context containerContext = (Context) context.lookup("java:comp/env"); return (DataSource) containerContext.lookup(dataAccessConfiguration.getDbConnectionString()); } catch (NamingException e) { throw new RuntimeException("Could not get dataSource from context, we have no DB connectivity"); } }--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.