2

Connection read-only mode is not enforceable after the connection has been established. To enforce a read only connection, set the read-only data source or connection property. ERRORCODE=4474, SQLSTATE=01000

Here is my Cotroller

package com.course.springbootstarter.topic;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMethod;

@RestController
public class TopicController {

    @Autowired
    private TopicService topicService;

    @RequestMapping(method = RequestMethod.GET, value = "/topics")
    public List<Topic> getAllTopics() {
        return topicService.getAllTopics();
    }

    @RequestMapping(method = RequestMethod.GET, value = "/topics/{id}")
    public Topic getTopic(@PathVariable long id) {
        return topicService.getTopic(id);
    }

    @RequestMapping(method = RequestMethod.POST, value = "/addtopic")
    public void addTopic(@RequestBody Topic topic) {
        topicService.addTopic(topic);
    }

    @RequestMapping(method = RequestMethod.PUT, value = "/updatetopic/{id}")
    public void updateTopic(@RequestBody Topic topic, @PathVariable long id) {
        topicService.updateTopic(id, topic);
    }


}
Topic.java

package com.course.springbootstarter.topic;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

@Entity
@Table(name = "course")
public class Topic {

    private static final long serialVersionUID = -3009157732242241606L;
    @Id
    //@GeneratedValue(strategy = GenerationType.AUTO)
    private long id;
    private String name;
    private String description;

    public Topic() {

    }

    public Topic(long id, String name, String description) {
        super();
        this.id = id;
        this.name = name;
        this.description = description;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

}

I get this error message:

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v1.4.3.RELEASE)

2019-03-20 10:43:39.947  INFO 10740 --- [           main] c.course.springbootstarter.CourseApiApp  : Starting CourseApiApp on IRL103021 with PID 10740 (C:\Users\c166422\Documents\github\springboot-restful-mysql-master\target\classes started by c166422 in C:\Users\c166422\Documents\github\springboot-restful-mysql-master)
2019-03-20 10:43:39.953  INFO 10740 --- [           main] c.course.springbootstarter.CourseApiApp  : The following profiles are active: demo
2019-03-20 10:43:40.156  INFO 10740 --- [           main] ationConfigEmbeddedWebApplicationContext : Refreshing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@f61c7b6: startup date [Wed Mar 20 10:43:40 CDT 2019]; root of context hierarchy
2019-03-20 10:43:43.564  INFO 10740 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [class org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$45faa968] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2019-03-20 10:43:45.279  INFO 10740 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat initialized with port(s): 8080 (http)
2019-03-20 10:43:45.307  INFO 10740 --- [           main] o.apache.catalina.core.StandardService   : Starting service Tomcat
2019-03-20 10:43:45.309  INFO 10740 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.6
2019-03-20 10:43:45.557  INFO 10740 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2019-03-20 10:43:45.560  INFO 10740 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 5408 ms
2019-03-20 10:43:46.161  INFO 10740 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Mapping servlet: 'dispatcherServlet' to [/]
2019-03-20 10:43:46.201  INFO 10740 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2019-03-20 10:43:46.211  INFO 10740 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2019-03-20 10:43:46.213  INFO 10740 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]
2019-03-20 10:43:46.220  INFO 10740 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'requestContextFilter' to: [/*]
2019-03-20 10:43:47.813  INFO 10740 --- [           main] j.LocalContainerEntityManagerFactoryBean : Building JPA container EntityManagerFactory for persistence unit 'default'
2019-03-20 10:43:47.895  INFO 10740 --- [           main] o.hibernate.jpa.internal.util.LogHelper  : HHH000204: Processing PersistenceUnitInfo [
        name: default
        ...]
2019-03-20 10:43:48.233  INFO 10740 --- [           main] org.hibernate.Version                    : HHH000412: Hibernate Core {5.0.11.Final}
2019-03-20 10:43:48.239  INFO 10740 --- [           main] org.hibernate.cfg.Environment            : HHH000206: hibernate.properties not found
2019-03-20 10:43:48.248  INFO 10740 --- [           main] org.hibernate.cfg.Environment            : HHH000021: Bytecode provider name : javassist
2019-03-20 10:43:48.428  INFO 10740 --- [           main] o.hibernate.annotations.common.Version   : HCANN000001: Hibernate Commons Annotations {5.0.1.Final}
2019-03-20 10:43:48.776  INFO 10740 --- [           main] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.DB2Dialect
2019-03-20 10:43:49.896  INFO 10740 --- [           main] org.hibernate.tool.hbm2ddl.SchemaUpdate  : HHH000228: Running hbm2ddl schema update
2019-03-20 10:43:50.052  INFO 10740 --- [           main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2019-03-20 10:43:51.515  INFO 10740 --- [           main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@f61c7b6: startup date [Wed Mar 20 10:43:40 CDT 2019]; root of context hierarchy
2019-03-20 10:43:51.783  INFO 10740 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/topics/{id}],methods=[GET]}" onto public com.course.springbootstarter.topic.Topic com.course.springbootstarter.topic.TopicController.getTopic(long)
2019-03-20 10:43:51.788  INFO 10740 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/addtopic],methods=[POST]}" onto public void com.course.springbootstarter.topic.TopicController.addTopic(com.course.springbootstarter.topic.Topic)
2019-03-20 10:43:51.791  INFO 10740 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/updatetopic/{id}],methods=[PUT]}" onto public void com.course.springbootstarter.topic.TopicController.updateTopic(com.course.springbootstarter.topic.Topic,long)
2019-03-20 10:43:51.795  INFO 10740 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/topics],methods=[GET]}" onto public java.util.List<com.course.springbootstarter.topic.Topic> com.course.springbootstarter.topic.TopicController.getAllTopics()
2019-03-20 10:43:51.823  INFO 10740 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error]}" onto public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.BasicErrorController.error(javax.servlet.http.HttpServletRequest)
2019-03-20 10:43:51.844  INFO 10740 --- [           main] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped "{[/error],produces=[text/html]}" onto public org.springframework.web.servlet.ModelAndView org.springframework.boot.autoconfigure.web.BasicErrorController.errorHtml(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse)
2019-03-20 10:43:51.974  INFO 10740 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/webjars/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-20 10:43:51.976  INFO 10740 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-20 10:43:52.125  INFO 10740 --- [           main] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped URL path [/**/favicon.ico] onto handler of type [class org.springframework.web.servlet.resource.ResourceHttpRequestHandler]
2019-03-20 10:43:52.822  INFO 10740 --- [           main] o.s.j.e.a.AnnotationMBeanExporter        : Registering beans for JMX exposure on startup
2019-03-20 10:43:53.509  INFO 10740 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2019-03-20 10:43:53.663  INFO 10740 --- [           main] c.course.springbootstarter.CourseApiApp  : Started CourseApiApp in 14.767 seconds (JVM running for 21.743)
2019-03-20 10:44:03.727  INFO 10740 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring FrameworkServlet 'dispatcherServlet'
2019-03-20 10:44:03.731  INFO 10740 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization started
2019-03-20 10:44:03.820  INFO 10740 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : FrameworkServlet 'dispatcherServlet': initialization completed in 88 ms
2019-03-20 10:44:03.976  INFO 10740 --- [nio-8080-exec-1] o.h.h.i.QueryTranslatorFactoryInitiator  : HHH000397: Using ASTQueryTranslatorFactory
2019-03-20 10:44:04.433  WARN 10740 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : SQL Warning Code: 4474, SQLState: 01000
2019-03-20 10:44:04.434  WARN 10740 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper   : [jcc][t4][10217][10310][4.19.66] Connection read-only mode is not enforceable after the connection has been established.
To enforce a read only connection, set the read-only data source or connection property. ERRORCODE=4474, SQLSTATE=01000
Andreas Lorenzen
  • 3,810
  • 1
  • 24
  • 26
Titi
  • 103
  • 1
  • 3
  • 12
  • I think you need to show us your application.properties (also for the environment that you are starting here). And tell us what you have tried to solve this? And, also - what database are you using and where is it located? – Andreas Lorenzen Mar 20 '19 at 16:02
  • spring.datasource.driver-class-name=com.ibm.db2.jcc.DB2Driver spring.datasource.url=jdbc:db2://lddb2data00001:50002/COURSESCHEM spring.datasource.username=db2user spring.datasource.password=db2password spring.jpa.generate-ddl=true spring.mvc.view.prefix: / spring.mvc.view.suffix: .jsp spring.profiles.active=demo – Titi Mar 20 '19 at 16:28
  • see also: https://www-01.ibm.com/support/docview.wss?uid=swg21685228 – xerx593 Mar 20 '19 at 18:02
  • title it rather "warning" than "error". – xerx593 Mar 20 '19 at 19:55

2 Answers2

3

This message can be ignored. I have not found it to have any impact on the application. However, if you wish to suppress this warning

  1. You can change the logger level.
  2. You can suppress all the warnings

follow this for more information Link

  • # Root logger option log4j.rootLogger=INFO, file # Direct log messages to a log file log4j.appender.file=org.apache.log4j.RollingFileAppender #Redirect to Tomcat logs folder #log4j.appender.file.File=${catalina.home}/logs/logging.log log4j.appender.file.File=C:\\logigng.log log4j.appender.file.MaxFileSize=10MB log4j.appender.file.MaxBackupIndex=10 log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n log4j.logger.org.hibernate.util.JDBCExceptionReporter=ERROR – Titi Mar 20 '19 at 18:37
  • I tried suppressing all the warnings by adding this log4j.logger.org.hibernate.util.JDBCExceptionReporter=ERROR in log4j.properties but still getting the same error message. Connection read-only mode is not enforceable after the connection has been established. To enforce a read only connection, set the read-only data source or connection property. ERRORCODE=4474, SQLSTATE=01000 – Titi Mar 20 '19 at 18:40
  • try: `log4j.logger.org.hibernate.engine.jdbc.spi.SqlExceptionHelper` or even `log4j.logger.org.hibernate` (it works "hierarchical", "by logger name/category"), @Titi – xerx593 Mar 20 '19 at 19:53
  • What's the value to log4j.logger.org.hibernate.engine.jdbc.spi.SqlExceptionHelper log4j.logger.org.hibernate can you write a complete answer? @xerx593 – Titi Mar 20 '19 at 20:05
  • @Titi ...actually *I like* /am satisfied, with this answer here (to your original question)! (+1) ..i meant/sounds ok: `= ERROR`. For more details on "hibernate logging configuration", i would refer you to [this nice answer](https://stackoverflow.com/a/436687/592355). – xerx593 Mar 20 '19 at 20:09
2

Issue fixed by adding this line to log4j.properties. Thanks to @xerx593

log4j.logger.org.hibernate.engine.jdbc.spi.SqlExceptionHelper=ERROR 
Titi
  • 103
  • 1
  • 3
  • 12
  • welcome, bro! :) (to clarify: First line sets the (level treshold to `ERROR`) for a specific logger/category/(class) name (see your original log!). Second line sets (...) generally (for complete "hibernate logging")). – xerx593 Mar 20 '19 at 20:26
  • with given facts, i am "pretty sure" that the second line works! to test the first line only, try it "stand-alone" (without/comment second line). – xerx593 Mar 20 '19 at 20:35
  • 1
    @xerx593, you're correct! I only need this line to fix this issue log4j.logger.org.hibernate.engine.jdbc.spi.SqlExceptionHelper=ERROR – Titi Mar 20 '19 at 20:56
  • for clarification: your originally (commented) logger name seems to refer to an older hibernate version: `log4j.logger.org.hibernate.util.JDBCExceptionReporter=...`, i found the actual one via the "class name" (it is "not default" but "common practice" to name loggers by (fully qualified) class name) in (the logs of) your post: `2019-03-20 10:44:04.433 WARN 10740 --- [nio-8080-exec-1] o.h.engine.jdbc.spi.SqlExceptionHelper : SQL Warning...`. – xerx593 Mar 20 '19 at 21:00