Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
478 views
in Technique[技术] by (71.8m points)

java - Trying to GET one topic http://localhost:8080/topics?id=1 in POSTMAN. Got the following error

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:Usersc166422Documentsgithubspringboot-restful-mysql-masterargetclasses started by c166422 in C:Usersc166422Documentsgithubspringboot-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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...