Date&Time in java codes&XML

本文探讨了Java中日期与时间处理的问题,特别是从Java.util.Date到XML datetime的转换过程,并提出了一种解决方案来确保时间准确无误。
 Date&Time in java codes&XML
 Problem Description
The path of the Time is,
 
Java.util.Date --> XML: datetime --> Java.util.Calendar.getTime()
 
If we have not done any additional change for the Time functions, the result in the end will be many hours away from the actual time.
 
One possible Solution
java.util.Date nowdate=new java.util.Date();    
nowdate.setTime(nowdate.getTime()
-nowdate.getTimezoneOffset()*60*1000);

ps:  getTimezoneOffset():  unit is minute
         setTime() and getTime(): unit is millisecond

Calendar CaseStartDate = srs.getCaseDateInfo().getCaseStartDate();
nowdate
=CaseStarDate.getTime();// Get day and time
2025-03-06T15:23:49.000Z这是前端传来的rg.springframework.web.bind.MethodArgumentNotValidException: Validation failed for argument [0] in public com.xymzsfxy.backend.returncode.Result com.xymzsfxy.backend.controller.admin.ProductController.update(com.xymzsfxy.backend.entity.Product) with 2 errors: [Field error in object ‘product’ on field ‘createdTime’: rejected value [2025-03-06T15:23:49.000Z]; codes [typeMismatch.product.createdTime,typeMismatch.createdTime,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [product.createdTime,createdTime]; arguments []; default message [createdTime]]; default message [Failed to convert property value of type ‘java.lang.String’ to required type ‘java.util.Date’ for property ‘createdTime’; Failed to convert from type [java.lang.String] to type [@javax.persistence.Column @com.fasterxml.jackson.annotation.JsonFormat java.util.Date] for value [2025-03-06T15:23:49.000Z]]] [Field error in object ‘product’ on field ‘updatedTime’: rejected value [2025-03-06T15:23:49.000Z]; codes [typeMismatch.product.updatedTime,typeMismatch.updatedTime,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [product.updatedTime,updatedTime]; arguments []; default message [updatedTime]]; default message [Failed to convert property value of type ‘java.lang.String’ to required type ‘java.util.Date’ for property ‘updatedTime’; Failed to convert from type [java.lang.String] to type [@javax.persistence.Column @com.fasterxml.jackson.annotation.JsonFormat java.util.Date] for value [2025-03-06T15:23:49.000Z]]] at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:177) at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:122) at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:179) 怎么修改
03-09
2025-09-25 16:30:11.510 [reactor-http-nio-2] DEBUG reactor.netty.http.server.HttpServerOperations - [fa9cb8bd, L:/127.0.0.1:9002 - R:/127.0.0.1:11613] New http connection, requesting read 2025-09-25 16:30:11.510 [reactor-http-nio-2] DEBUG reactor.netty.transport.TransportConfig - [fa9cb8bd, L:/127.0.0.1:9002 - R:/127.0.0.1:11613] Initialized pipeline DefaultChannelPipeline{(reactor.left.httpCodec = io.netty.handler.codec.http.HttpServerCodec), (reactor.left.httpTrafficHandler = reactor.netty.http.server.HttpTrafficHandler), (reactor.right.reactiveBridge = reactor.netty.channel.ChannelOperationsHandler)} 2025-09-25 16:30:11.582 [reactor-http-nio-2] DEBUG reactor.netty.http.server.HttpServerOperations - [fa9cb8bd, L:/127.0.0.1:9002 - R:/127.0.0.1:11613] Increasing pending responses, now 1 2025-09-25 16:30:11.649 [reactor-http-nio-2] DEBUG reactor.netty.http.server.HttpServer - [fa9cb8bd-1, L:/127.0.0.1:9002 - R:/127.0.0.1:11613] Handler is being applied: org.springframework.http.server.reactive.ReactorHttpHandlerAdapter@558f6c01 2025-09-25 16:30:11.778 [reactor-http-nio-2] DEBUG o.s.web.server.adapter.HttpWebHandlerAdapter - [fa9cb8bd-1] HTTP POST "/asn/main/query" 2025-09-25 16:30:11.854 [reactor-http-nio-2] DEBUG o.s.w.r.r.m.a.RequestMappingHandlerMapping - [fa9cb8bd-1] Mapped to com.hvlink.controller.AsnMainController#queryPage(AsnParam) 2025-09-25 16:30:11.895 [reactor-http-nio-2] DEBUG o.s.w.r.r.m.a.RequestBodyMethodArgumentResolver - [fa9cb8bd-1] Content-Type:application/json 2025-09-25 16:30:11.922 [reactor-http-nio-2] DEBUG o.s.w.r.r.m.a.RequestBodyMethodArgumentResolver - [fa9cb8bd-1] 0..1 [com.hvlink.entity.param.asn.AsnParam] 2025-09-25 16:30:11.992 [reactor-http-nio-2] DEBUG reactor.netty.channel.FluxReceive - [fa9cb8bd-1, L:/127.0.0.1:9002 - R:/127.0.0.1:11613] [terminated=false, cancelled=false, pending=0, error=null]: subscribing inbound receiver 2025-09-25 16:30:12.220 [reactor-http-nio-2] DEBUG o.s.http.codec.json.Jackson2JsonDecoder - [fa9cb8bd-1] Decoded [AsnParam(factoryCode=null, factoryName=null, asnNo=null, orderNo=null, partCode=null, partDesc=null, (truncated)...] 2025-09-25 16:30:12.318 [reactor-http-nio-2] DEBUG org.mybatis.spring.SqlSessionUtils - Creating a new SqlSession 2025-09-25 16:30:12.369 [reactor-http-nio-2] DEBUG org.mybatis.spring.SqlSessionUtils - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@735e184b] was not registered for synchronization because synchronization is not active 2025-09-25 16:30:13.124 [reactor-http-nio-2] DEBUG o.springframework.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource 2025-09-25 16:30:13.124 [reactor-http-nio-2] DEBUG o.m.spring.transaction.SpringManagedTransaction - JDBC Connection [ConnectionID:1 ClientConnectionId: ef17a568-9c82-4c0e-9f59-8ce01ca16f34] will not be managed by Spring 2025-09-25 16:30:13.139 [reactor-http-nio-2] DEBUG c.h.mapper.asn.AsnMainMapper.queryAsnPage_mpCount - ==> Preparing: SELECT COUNT(*) AS total FROM (SELECT ROW_NUMBER() OVER (ORDER BY am.create_time DESC, am.asn_no DESC, am.id DESC) AS RowNum, am.id, am.factory_code AS factoryCode, am.warehouse_code AS warehouseCode, am.shipper_id AS shipperId, am.asn_no AS asnNo, am.status, am.production_batch AS productionBatch, am.shipping_date AS shippingDate, am.estimated_arrival_date AS estimatedArrivalDate, am.estimated_consumption_time AS estimatedConsumptionTime, am.is_first_product AS isFirstProduct, am.is_fully_shipping AS isFullyShipping, am.release_date AS releaseDate, am.is_deleted AS isDeleted, am.create_user AS createUser, am.update_user AS updateUser, am.create_time AS createTime, am.update_time AS updateTime, f.factory_name AS factoryName, w.warehouse_name AS warehouseName, s.shipper_name AS shipperName, sup.supplier_code AS supplierCode, sup.supplier_name AS supplierName FROM tb_asn_main am LEFT JOIN tm_factory f ON am.factory_code = f.factory_code LEFT JOIN tm_warehouse w ON am.warehouse_code = w.warehouse_code LEFT JOIN tm_shipper s ON am.shipper_id = s.id LEFT JOIN tm_supplier sup ON s.supplier_code = sup.supplier_code WHERE am.is_deleted = 0) AS T WHERE RowNum BETWEEN ? * (? - 1) + 1 AND ? * ? 2025-09-25 16:30:13.333 [reactor-http-nio-2] DEBUG c.h.mapper.asn.AsnMainMapper.queryAsnPage_mpCount - ==> Parameters: 10(Long), 1(Long), 10(Long), 1(Long) 2025-09-25 16:30:13.546 [reactor-http-nio-2] DEBUG c.h.mapper.asn.AsnMainMapper.queryAsnPage_mpCount - <== Total: 1 2025-09-25 16:30:13.560 [reactor-http-nio-2] DEBUG com.hvlink.mapper.asn.AsnMainMapper.queryAsnPage - ==> Preparing: SELECT * FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY am.create_time DESC, am.asn_no DESC, am.id DESC ) AS RowNum, am.id, am.factory_code AS factoryCode, am.warehouse_code AS warehouseCode, am.shipper_id AS shipperId, am.asn_no AS asnNo, am.status, am.production_batch AS productionBatch, am.shipping_date AS shippingDate, am.estimated_arrival_date AS estimatedArrivalDate, am.estimated_consumption_time AS estimatedConsumptionTime, am.is_first_product AS isFirstProduct, am.is_fully_shipping AS isFullyShipping, am.release_date AS releaseDate, am.is_deleted AS isDeleted, am.create_user AS createUser, am.update_user AS updateUser, am.create_time AS createTime, am.update_time AS updateTime, f.factory_name AS factoryName, w.warehouse_name AS warehouseName, s.shipper_name AS shipperName, sup.supplier_code AS supplierCode, sup.supplier_name AS supplierName FROM tb_asn_main am LEFT JOIN tm_factory f ON am.factory_code = f.factory_code LEFT JOIN tm_warehouse w ON am.warehouse_code = w.warehouse_code LEFT JOIN tm_shipper s ON am.shipper_id = s.id LEFT JOIN tm_supplier sup ON s.supplier_code = sup.supplier_code WHERE am.is_deleted = 0 ) AS T WHERE RowNum BETWEEN ? * (? - 1) + 1 AND ? * ? OFFSET ? ROWS FETCH NEXT ? ROWS ONLY 2025-09-25 16:30:13.561 [reactor-http-nio-2] DEBUG com.hvlink.mapper.asn.AsnMainMapper.queryAsnPage - ==> Parameters: 10(Long), 1(Long), 10(Long), 1(Long), 0(Long), 10(Long) 2025-09-25 16:30:13.679 [reactor-http-nio-2] DEBUG org.mybatis.spring.SqlSessionUtils - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@735e184b] 2025-09-25 16:30:13.792 [reactor-http-nio-2] DEBUG o.s.beans.factory.xml.XmlBeanDefinitionReader - Loaded 11 bean definitions from class path resource [org/springframework/jdbc/support/sql-error-codes.xml] 2025-09-25 16:30:13.793 [reactor-http-nio-2] DEBUG o.s.b.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'DB2' 2025-09-25 16:30:13.812 [reactor-http-nio-2] DEBUG o.s.b.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'Derby' 2025-09-25 16:30:13.812 [reactor-http-nio-2] DEBUG o.s.b.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'H2' 2025-09-25 16:30:13.812 [reactor-http-nio-2] DEBUG o.s.b.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'HDB' 2025-09-25 16:30:13.815 [reactor-http-nio-2] DEBUG o.s.b.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'HSQL' 2025-09-25 16:30:13.816 [reactor-http-nio-2] DEBUG o.s.b.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'Informix' 2025-09-25 16:30:13.817 [reactor-http-nio-2] DEBUG o.s.b.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'MS-SQL' 2025-09-25 16:30:13.817 [reactor-http-nio-2] DEBUG o.s.b.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'MySQL' 2025-09-25 16:30:13.817 [reactor-http-nio-2] DEBUG o.s.b.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'Oracle' 2025-09-25 16:30:13.818 [reactor-http-nio-2] DEBUG o.s.b.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'PostgreSQL' 2025-09-25 16:30:13.819 [reactor-http-nio-2] DEBUG o.s.b.factory.support.DefaultListableBeanFactory - Creating shared instance of singleton bean 'Sybase' 2025-09-25 16:30:13.819 [reactor-http-nio-2] DEBUG o.s.jdbc.support.SQLErrorCodesFactory - Looking up default SQLErrorCodes for DataSource [com.hvlink.config.DataSourceConfig$1@36b886] 2025-09-25 16:30:13.828 [reactor-http-nio-2] DEBUG o.springframework.jdbc.datasource.DataSourceUtils - Fetching JDBC Connection from DataSource 2025-09-25 16:30:13.833 [reactor-http-nio-2] DEBUG o.s.jdbc.support.SQLErrorCodesFactory - SQL error codes for 'Microsoft SQL Server' found 2025-09-25 16:30:13.833 [reactor-http-nio-2] DEBUG o.s.jdbc.support.SQLErrorCodesFactory - Caching SQL error codes for DataSource [com.hvlink.config.DataSourceConfig$1@36b886]: database product name is 'Microsoft SQL Server' 2025-09-25 16:30:13.835 [reactor-http-nio-2] DEBUG o.s.j.support.SQLErrorCodeSQLExceptionTranslator - Unable to translate SQLException with Error code '102', will now try the fallback translator 2025-09-25 16:30:13.836 [reactor-http-nio-2] DEBUG o.s.jdbc.support.SQLStateSQLExceptionTranslator - Extracted SQL state class 'S0' from value 'S0001' 2025-09-25 16:30:13.873 [reactor-http-nio-2] ERROR com.hvlink.controller.AsnMainController - ASN查询失败 org.springframework.jdbc.UncategorizedSQLException: ### Error querying database. Cause: com.microsoft.sqlserver.jdbc.SQLServerException: “OFFSET”附近有语法错误。 ### The error may exist in file [D:\SHProjects\hv-link-backend\dao\target\classes\mapper\asn\TbAsnOrderMain.xml] ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: SELECT * FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY am.create_time DESC, am.asn_no DESC, am.id DESC ) AS RowNum, am.id, am.factory_code AS factoryCode, am.warehouse_code AS warehouseCode, am.shipper_id AS shipperId, am.asn_no AS asnNo, am.status, am.production_batch AS productionBatch, am.shipping_date AS shippingDate, am.estimated_arrival_date AS estimatedArrivalDate, am.estimated_consumption_time AS estimatedConsumptionTime, am.is_first_product AS isFirstProduct, am.is_fully_shipping AS isFullyShipping, am.release_date AS releaseDate, am.is_deleted AS isDeleted, am.create_user AS createUser, am.update_user AS updateUser, am.create_time AS createTime, am.update_time AS updateTime, f.factory_name AS factoryName, w.warehouse_name AS warehouseName, s.shipper_name AS shipperName, sup.supplier_code AS supplierCode, sup.supplier_name AS supplierName FROM tb_asn_main am LEFT JOIN tm_factory f ON am.factory_code = f.factory_code LEFT JOIN tm_warehouse w ON am.warehouse_code = w.warehouse_code LEFT JOIN tm_shipper s ON am.shipper_id = s.id LEFT JOIN tm_supplier sup ON s.supplier_code = sup.supplier_code WHERE am.is_deleted = 0 ) AS T WHERE RowNum BETWEEN ? * (? - 1) + 1 AND ? * ? OFFSET ? ROWS FETCH NEXT ? ROWS ONLY ### Cause: com.microsoft.sqlserver.jdbc.SQLServerException: “OFFSET”附近有语法错误。 ; uncategorized SQLException; SQL state [S0001]; error code [102]; “OFFSET”附近有语法错误。; nested exception is com.microsoft.sqlserver.jdbc.SQLServerException: “OFFSET”附近有语法错误。 at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:92) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy113.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForIPage(MybatisMapperMethod.java:121) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:85) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) at com.sun.proxy.$Proxy117.queryAsnPage(Unknown Source) at com.hvlink.service.impl.AsnMainServiceImpl.queryPage(AsnMainServiceImpl.java:325) at com.hvlink.service.impl.AsnMainServiceImpl$$FastClassBySpringCGLIB$$906a1c7c.invoke(<generated>) at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:218) at org.springframework.aop.framework.CglibAopProxy.invokeMethod(CglibAopProxy.java:386) at org.springframework.aop.framework.CglibAopProxy.access$000(CglibAopProxy.java:85) at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:703) at com.hvlink.service.impl.AsnMainServiceImpl$$EnhancerBySpringCGLIB$$ed203fe9.queryPage(<generated>) at com.hvlink.controller.AsnMainController.queryPage(AsnMainController.java:51) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.springframework.web.reactive.result.method.InvocableHandlerMethod.lambda$invoke$0(InvocableHandlerMethod.java:145) at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:125) at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:539) at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1839) at reactor.core.publisher.MonoZip$ZipCoordinator.signal(MonoZip.java:258) at reactor.core.publisher.MonoZip$ZipInner.onNext(MonoZip.java:347) at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:539) at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onNext(MonoPeekTerminal.java:180) at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:539) at reactor.core.publisher.FluxDefaultIfEmpty$DefaultIfEmptySubscriber.onNext(FluxDefaultIfEmpty.java:101) at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:539) at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onNext(FluxPeekFuseable.java:210) at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:539) at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:74) at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:539) at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79) at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:539) at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1839) at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:151) at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onNext(FluxContextWrite.java:107) at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:539) at reactor.core.publisher.FluxMapFuseable$MapFuseableConditionalSubscriber.onNext(FluxMapFuseable.java:299) at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:539) at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:337) at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onNext(FluxOnAssembly.java:539) at reactor.core.publisher.Operators$MonoSubscriber.complete(Operators.java:1839) at reactor.core.publisher.MonoCollect$CollectSubscriber.onComplete(MonoCollect.java:160) at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onComplete(FluxOnAssembly.java:549) at reactor.core.publisher.FluxMapFuseable$MapFuseableSubscriber.onComplete(FluxMapFuseable.java:152) at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onComplete(FluxOnAssembly.java:549) at reactor.core.publisher.FluxPeekFuseable$PeekFuseableSubscriber.onComplete(FluxPeekFuseable.java:277) at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onComplete(FluxOnAssembly.java:549) at reactor.core.publisher.FluxMap$MapSubscriber.onComplete(FluxMap.java:144) at reactor.netty.channel.FluxReceive.onInboundComplete(FluxReceive.java:415) at reactor.netty.channel.ChannelOperations.onInboundComplete(ChannelOperations.java:439) at reactor.netty.http.server.HttpServerOperations.onInboundNext(HttpServerOperations.java:656) at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:114) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) at reactor.netty.http.server.HttpTrafficHandler.channelRead(HttpTrafficHandler.java:276) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:436) at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:318) at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:251) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412) at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:788) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:724) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:650) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:562) at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997) at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:750) Caused by: com.microsoft.sqlserver.jdbc.SQLServerException: “OFFSET”附近有语法错误。 at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:259) at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1695) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:648) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:567) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7675) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:4137) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:272) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:246) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.execute(SQLServerPreparedStatement.java:544) at com.alibaba.druid.pool.DruidPooledPreparedStatement.execute(DruidPooledPreparedStatement.java:483) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.logging.jdbc.PreparedStatementLogger.invoke(PreparedStatementLogger.java:59) at com.sun.proxy.$Proxy212.execute(Unknown Source) at org.apache.ibatis.executor.statement.PreparedStatementHandler.query(PreparedStatementHandler.java:64) at org.apache.ibatis.executor.statement.RoutingStatementHandler.query(RoutingStatementHandler.java:79) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:64) at com.sun.proxy.$Proxy210.query(Unknown Source) at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:63) at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:325) at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:156) at com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor.intercept(MybatisPlusInterceptor.java:81) at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:62) at com.sun.proxy.$Proxy209.query(Unknown Source) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:151) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:145) at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:140) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:427) ... 83 common frames omitted 2025-09-25 16:30:13.892 [reactor-http-nio-2] DEBUG o.s.w.r.r.m.annotation.ResponseBodyResultHandler - [fa9cb8bd-1] Using 'application/json' given [*/*] and supported [application/json, application/*+json, application/x-ndjson, text/event-stream] 2025-09-25 16:30:13.892 [reactor-http-nio-2] DEBUG o.s.w.r.r.m.annotation.ResponseBodyResultHandler - [fa9cb8bd-1] 0..1 [com.hvlink.common.Result<com.hvlink.pagination.PageResult<com.hvlink.entity.vo.asn.AsnMainVO>>] 2025-09-25 16:30:13.936 [reactor-http-nio-2] DEBUG o.s.http.codec.json.Jackson2JsonEncoder - [fa9cb8bd-1] Encoding [Result(status=500, msg=ASN查询失败, data=null, timestamp=1758789013883)] 2025-09-25 16:30:13.995 [reactor-http-nio-2] DEBUG reactor.netty.http.server.HttpServerOperations - [fa9cb8bd-1, L:/127.0.0.1:9002 - R:/127.0.0.1:11613] Decreasing pending responses, now 0 2025-09-25 16:30:13.995 [reactor-http-nio-2] DEBUG reactor.netty.http.server.HttpServerOperations - [fa9cb8bd-1, L:/127.0.0.1:9002 - R:/127.0.0.1:11613] Last HTTP packet was sent, terminating the channel 2025-09-25 16:30:13.996 [reactor-http-nio-2] DEBUG reactor.netty.channel.ChannelOperations - [fa9cb8bd-1, L:/127.0.0.1:9002 - R:/127.0.0.1:11613] [HttpServer] Channel inbound receiver cancelled (operation cancelled). 2025-09-25 16:30:14.017 [reactor-http-nio-2] DEBUG o.s.web.server.adapter.HttpWebHandlerAdapter - [fa9cb8bd-1] Completed 200 OK 2025-09-25 16:30:14.024 [reactor-http-nio-2] DEBUG reactor.netty.http.server.HttpServerOperations - [fa9cb8bd-1, L:/127.0.0.1:9002 - R:/127.0.0.1:11613] Last HTTP response frame <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.hvlink.mapper.asn.AsnMainMapper"> <!-- ASN主表分页查询 --> <select id="queryAsnPage" resultType="com.hvlink.entity.dto.asn.AsnMainDTO"> SELECT * FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY am.create_time DESC, am.asn_no DESC, am.id DESC ) AS RowNum, am.id, am.factory_code AS factoryCode, am.warehouse_code AS warehouseCode, am.shipper_id AS shipperId, am.asn_no AS asnNo, am.status, am.production_batch AS productionBatch, am.shipping_date AS shippingDate, am.estimated_arrival_date AS estimatedArrivalDate, am.estimated_consumption_time AS estimatedConsumptionTime, am.is_first_product AS isFirstProduct, am.is_fully_shipping AS isFullyShipping, am.release_date AS releaseDate, am.is_deleted AS isDeleted, am.create_user AS createUser, am.update_user AS updateUser, am.create_time AS createTime, am.update_time AS updateTime, f.factory_name AS factoryName, w.warehouse_name AS warehouseName, s.shipper_name AS shipperName, sup.supplier_code AS supplierCode, sup.supplier_name AS supplierName FROM tb_asn_main am LEFT JOIN tm_factory f ON am.factory_code = f.factory_code LEFT JOIN tm_warehouse w ON am.warehouse_code = w.warehouse_code LEFT JOIN tm_shipper s ON am.shipper_id = s.id LEFT JOIN tm_supplier sup ON s.supplier_code = sup.supplier_code WHERE am.is_deleted = 0 <!-- 工厂条件 --> <if test="param.factoryCode != null and param.factoryCode != ''"> AND am.factory_code LIKE CONCAT('%', #{param.factoryCode}, '%') </if> <!-- 仓库条件 --> <if test="param.warehouseCode != null and param.warehouseCode != ''"> AND am.warehouse_code LIKE CONCAT('%', #{param.warehouseCode}, '%') </if> <!-- ASN号条件 --> <if test="param.asnNo != null and param.asnNo != ''"> AND am.asn_no LIKE CONCAT('%', #{param.asnNo}, '%') </if> <!-- 订单号条件(关联明细表查询) --> <if test="param.orderNo != null and param.orderNo != ''"> AND EXISTS ( SELECT 1 FROM tb_asn_detail ad WHERE ad.asn_no = am.asn_no AND ad.is_deleted = 0 AND ad.order_no LIKE CONCAT('%', #{param.orderNo}, '%') ) </if> <!-- 零件号条件(关联明细表查询) --> <if test="param.partCode != null and param.partCode != ''"> AND EXISTS ( SELECT 1 FROM tb_asn_detail ad WHERE ad.asn_no = am.asn_no AND ad.is_deleted = 0 AND ad.part_code LIKE CONCAT('%', #{param.partCode}, '%') ) </if> <!-- 零件描述条件(关联明细表查询) --> <if test="param.partDesc != null and param.partDesc != ''"> AND EXISTS ( SELECT 1 FROM tb_asn_detail ad WHERE ad.asn_no = am.asn_no AND ad.is_deleted = 0 AND ad.part_desc LIKE CONCAT('%', #{param.partDesc}, '%') ) </if> <!-- 发货方条件 --> <if test="param.shipperName != null and param.shipperName != ''"> AND s.shipper_name LIKE CONCAT('%', #{param.shipperName}, '%') </if> <!-- 状态条件 --> <if test="param.status != null and param.status != ''"> AND am.status = #{param.status} </if> <!-- 供应商条件 --> <if test="param.supplierCode != null and param.supplierCode != ''"> AND sup.supplier_code LIKE CONCAT('%', #{param.supplierCode}, '%') </if> <if test="param.supplierName != null and param.supplierName != ''"> AND sup.supplier_name LIKE CONCAT('%', #{param.supplierName}, '%') </if> <!-- 创建日期范围 --> <if test="param.createStartDate != null"> AND am.create_time >= #{param.createStartDate} </if> <if test="param.createEndDate != null"> AND am.create_time <= #{param.createEndDate} </if> <!-- 发布日期范围 --> <if test="param.releaseStartDate != null"> AND am.release_date >= #{param.releaseStartDate} </if> <if test="param.releaseEndDate != null"> AND am.release_date <= #{param.releaseEndDate} </if> ) AS T WHERE RowNum BETWEEN #{param.pageSize} * (#{param.pageIndex} - 1) + 1 AND #{param.pageSize} * #{param.pageIndex} </select> </mapper>
09-26
bin/sqoop import \ > --connect jdbc:mysql://192.168.249.161:3306/nev \ > --username hive \ > --password hive \ > --query "select > id,create_date_time,session_id,sid,create_time,seo_source,seo_keywords,ip,area, > country,province,city,origin_channel,user as > user_match,manual_time,begin_time,end_time,last_customer_msg_time_stamp,last_agent_msg_time_stamp, reply_msg_count,msg_count,browser_name,os_info from > web_chat_ems_2019_07 where 1=1 and \$CONDITIONS" \ > --hcatalog-database hnsoft_ods \ > --hcatalog-table web_chat_ems_ods \ > -m 2 \ > --split-by id Warning: /home/hadoop/app/sqoop/../hcatalog does not exist! HCatalog jobs will fail. Please set $HCAT_HOME to the root of your HCatalog installation. Warning: /home/hadoop/app/sqoop/../accumulo does not exist! Accumulo imports will fail. Please set $ACCUMULO_HOME to the root of your Accumulo installation. SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/home/hadoop/app/hadoop-2.9.2/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/hadoop/app/hbase-1.2.0/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory] 25/05/28 14:51:28 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6 25/05/28 14:51:28 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead. 25/05/28 14:51:28 INFO manager.MySQLManager: Preparing to use a MySQL streaming resultset. 25/05/28 14:51:28 INFO tool.CodeGenTool: Beginning code generation Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary. 25/05/28 14:51:29 INFO manager.SqlManager: Executing SQL statement: select id,create_date_time,session_id,sid,create_time,seo_source,seo_keywords,ip,area, country,province,city,origin_channel,user as user_match,manual_time,begin_time,end_time,last_customer_msg_time_stamp,last_agent_msg_time_stamp, reply_msg_count,msg_count,browser_name,os_info from web_chat_ems_2019_07 where 1=1 and (1 = 0) 25/05/28 14:51:30 INFO manager.SqlManager: Executing SQL statement: select id,create_date_time,session_id,sid,create_time,seo_source,seo_keywords,ip,area, country,province,city,origin_channel,user as user_match,manual_time,begin_time,end_time,last_customer_msg_time_stamp,last_agent_msg_time_stamp, reply_msg_count,msg_count,browser_name,os_info from web_chat_ems_2019_07 where 1=1 and (1 = 0) 25/05/28 14:51:30 INFO manager.SqlManager: Executing SQL statement: select id,create_date_time,session_id,sid,create_time,seo_source,seo_keywords,ip,area, country,province,city,origin_channel,user as user_match,manual_time,begin_time,end_time,last_customer_msg_time_stamp,last_agent_msg_time_stamp, reply_msg_count,msg_count,browser_name,os_info from web_chat_ems_2019_07 where 1=1 and (1 = 0) 25/05/28 14:51:30 INFO orm.CompilationManager: HADOOP_MAPRED_HOME is /home/hadoop/app/hadoop 注: /tmp/sqoop-root/compile/413c3b2426f9b2007f8209241e804082/QueryResult.java使用或覆盖了已过时的 API。 注: 有关详细信息, 请使用 -Xlint:deprecation 重新编译。 25/05/28 14:51:41 INFO orm.CompilationManager: Writing jar file: /tmp/sqoop-root/compile/413c3b2426f9b2007f8209241e804082/QueryResult.jar 25/05/28 14:51:41 INFO mapreduce.ImportJobBase: Beginning query import. 25/05/28 14:51:41 INFO Configuration.deprecation: mapred.jar is deprecated. Instead, use mapreduce.job.jar Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hive/hcatalog/mapreduce/HCatOutputFormat at org.apache.sqoop.mapreduce.DataDrivenImportJob.getOutputFormatClass(DataDrivenImportJob.java:178) at org.apache.sqoop.mapreduce.ImportJobBase.configureOutputFormat(ImportJobBase.java:94) at org.apache.sqoop.mapreduce.ImportJobBase.runImport(ImportJobBase.java:259) at org.apache.sqoop.manager.SqlManager.importQuery(SqlManager.java:729) at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:499) at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:605) at org.apache.sqoop.Sqoop.run(Sqoop.java:143) at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:76) at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:179) at org.apache.sqoop.Sqoop.runTool(Sqoop.java:218) at org.apache.sqoop.Sqoop.runTool(Sqoop.java:227) at org.apache.sqoop.Sqoop.main(Sqoop.java:236) Caused by: java.lang.ClassNotFoundException: org.apache.hive.hcatalog.mapreduce.HCatOutputFormat at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 12 more
05-29
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值