You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2021/12/29 01:23:29 UTC

[GitHub] [shardingsphere] liuziyi16 commented on issue #14386: execute INSERT throw java.util.NoSuchElementException(JDBC+MyBatisPlus)

liuziyi16 commented on issue #14386:
URL: https://github.com/apache/shardingsphere/issues/14386#issuecomment-1002351693


   Thanks for helping me so much!
   Actually the problem is that sharding-jdbc-spring-boot-starter(v4.1.1) cannot support to_date() in sql.
   And I find someone says it can be supported in shardingsphere-jdbc5.0.
   So I want to have a try.
   I would be very grateful if the problem can be solved with spring-boot2.3.2.
   
   There is my pom
   ```
   <dependencyManagement>                                                
       <dependencies>      
           <dependency>    
               <groupId>org.springframework.boot</groupId>    
               <artifactId>spring-boot-dependencies</artifactId>    
               <version>1.5.17.RELEASE</version>    
               <type>pom</type>    
               <scope>import</scope>    
           </dependency>    
           <dependency>    
               <groupId>org.springframework.cloud</groupId>    
               <artifactId>spring-cloud-dependencies</artifactId>
               <version>Hoxton.SR7</version>
               <type>pom</type>
               <scope>import</scope>
           </dependency>
       </dependencies>
   </dependencyManagement>
   <dependencies>          
       <dependency> 
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-web</artifactId>
       </dependency>
       <dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-test</artifactId>
       </dependency>
       <dependency>
           <groupId>org.apache.shardingsphere</groupId>
           <artifactId>shardingsphere-jdbc-core-spring-boot-starter</artifactId>
           <version>5.0.0</version>
       </dependency>
       <dependency>
           <groupId>com.baomidou</groupId>
           <artifactId>mybatis-plus-boot-starter</artifactId>
           <version>3.2.0</version>
       </dependency>
       <dependency>
           <groupId>com.alibaba</groupId>
           <artifactId>fastjson</artifactId>
           <version>1.2.75</version>
       </dependency>
       <dependency>
           <groupId>mysql</groupId>
           <artifactId>mysql-connector-java</artifactId>
       </dependency>
       <dependency>
           <groupId>com.alibaba</groupId>
           <artifactId>druid</artifactId>
           <version>1.2.6</version>
       </dependency>
   </dependencies>
   ```
   
   There is my application.properties
   ```
   spring.main.allow-bean-definition-overriding=true
   spring.shardingsphere.datasource.names=ds1,ds2
   spring.shardingsphere.datasource.ds1.type=com.alibaba.druid.pool.DruidDataSource
   spring.shardingsphere.datasource.ds1.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.ds1.url=jdbc:mysql://127.0.0.1:3306/test?serverTimezone=UTC&characterEncoding=UTF-8
   spring.shardingsphere.datasource.ds1.username=root
   spring.shardingsphere.datasource.ds1.password=123456
   spring.shardingsphere.datasource.ds2.type=com.alibaba.druid.pool.DruidDataSource
   spring.shardingsphere.datasource.ds2.driver-class-name=com.mysql.jdbc.Driver
   spring.shardingsphere.datasource.ds2.url=jdbc:mysql://127.0.0.1:3306/test2?serverTimezone=UTC&characterEncoding=UTF-8
   spring.shardingsphere.datasource.ds2.username=root
   spring.shardingsphere.datasource.ds2.password=123456
   spring.shardingsphere.sharding.default-data-source-name=ds1
   spring.shardingsphere.props.sql.show=true
   ```
   
   There is my sql
   ```
   <insert id="insert" parameterType="com.sharding.entity.Student">  
           insert into student (id,name,sex,birthday)       
           values        
           ( #{id}, #{name}, #{sex}, #{birthday})           
   </insert>
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org