在我的Spring应用程序中,我将jooq 3.15与r2dbc结合使用,但从DB中获取数据时遇到了问题。
我使用nu.studer。版本为6.0.1的jooq,用于在我的gradle文件中设置jooq:
jooq {
version.set("3.15.1")
edition.set(nu.studer.gradle.jooq.JooqEdition.OSS)
configurations {
create("main") {
generateSchemaSourceOnCompilation.set(false)
jooqConfiguration.apply {
logging = org.jooq.meta.jaxb.Logging.WARN
jdbc.apply {
driver = "org.postgresql.Driver"
url = "jdbc:postgresql://localhost:15432/core_ticker"
user = ""
password = ""
}
generator.apply {
database.apply {
name = "org.jooq.meta.postgres.PostgresDatabase"
inputSchema = "public"
includes = ".*"
excludes =
"flyway_schema_history"
}
generate.apply {
isRelations = true
isDeprecated = false
isRecords = true
isImmutablePojos = true
isFluentSetters = true
}
target.apply {
packageName = "rc.core.ticker.domain.db"
directory = "src/main/java"
}
}
}
}
}
}
下面是获取货币汇率的代码:
fun getRate(
fromCurrency: Currency,
toCurrency: Currency,
source: CurrencySource,
date: LocalDate?
) = Mono.from(
context.selectFrom(Tables.CURRENCY_RATE)
.where(Tables.CURRENCY_RATE.CURRENCY_FROM.eq(fromCurrency.value))
.and(Tables.CURRENCY_RATE.CURRENCY_TO.eq(toCurrency.value))
.limit(1)
).mapNotNull(CurrencyRate.Mapper::map).awaitSingle()
但我不会提取数据,因为Mono内部的代码出现异常。从带有下一个堆栈跟踪的:
java.lang.IllegalArgumentException: Cannot decode value of type java.lang.String with OID 51968
at io.r2dbc.postgresql.codec.DefaultCodecs.decode(DefaultCodecs.java:158) ~[r2dbc-postgresql-0.8.8.RELEASE.jar:0.8.8.RELEASE]
at io.r2dbc.postgresql.PostgresqlRow.decode(PostgresqlRow.java:90) ~[r2dbc-postgresql-0.8.8.RELEASE.jar:0.8.8.RELEASE]
at io.r2dbc.postgresql.PostgresqlRow.get(PostgresqlRow.java:67) ~[r2dbc-postgresql-0.8.8.RELEASE.jar:0.8.8.RELEASE]
at org.jooq.impl.R2DBC$R2DBCResultSet$DefaultRow.get(R2DBC.java:1110) ~[jooq-3.15.1.jar:na]
at org.jooq.impl.R2DBC$R2DBCResultSet.nullable(R2DBC.java:989) ~[jooq-3.15.1.jar:na]
at org.jooq.impl.R2DBC$R2DBCResultSet.nullable(R2DBC.java:985) ~[jooq-3.15.1.jar:na]
at org.jooq.impl.R2DBC$R2DBCResultSet.getString(R2DBC.java:1050) ~[jooq-3.15.1.jar:na]
at org.jooq.impl.DefaultBinding$DefaultEnumTypeBinding.get0(DefaultBinding.java:2560) ~[jooq-3.15.1.jar:na]
at org.jooq.impl.DefaultBinding$DefaultEnumTypeBinding.get0(DefaultBinding.java:2527) ~[jooq-3.15.1.jar:na]
at org.jooq.impl.DefaultBinding$AbstractBinding.get(DefaultBinding.java:942) ~[jooq-3.15.1.jar:na]
at org.jooq.impl.R2DBC$ResultSubscriber.lambda$onNext$0(R2DBC.java:327) ~[jooq-3.15.1.jar:na]
at org.jooq.impl.RecordDelegate.operate(RecordDelegate.java:143) ~[jooq-3.15.1.jar:na]
at org.jooq.impl.R2DBC$ResultSubscriber.lambda$onNext$1(R2DBC.java:313) ~[jooq-3.15.1.jar:na]
at io.r2dbc.postgresql.PostgresqlResult.lambda$map$1(PostgresqlResult.java:111) ~[r2dbc-postgresql-0.8.8.RELEASE.jar:0.8.8.RELEASE]
at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:103) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.MonoFlatMapMany$FlatMapManyInner.onNext(MonoFlatMapMany.java:250) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxHandleFuseable$HandleFuseableSubscriber.onNext(FluxHandleFuseable.java:184) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxFilterFuseable$FilterFuseableConditionalSubscriber.onNext(FluxFilterFuseable.java:337) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxContextWrite$ContextWriteSubscriber.onNext(FluxContextWrite.java:107) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxPeekFuseable$PeekConditionalSubscriber.onNext(FluxPeekFuseable.java:854) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxPeekFuseable$PeekConditionalSubscriber.onNext(FluxPeekFuseable.java:854) ~[reactor-core-3.4.9.jar:3.4.9]
at io.r2dbc.postgresql.util.FluxDiscardOnCancel$FluxDiscardOnCancelSubscriber.onNext(FluxDiscardOnCancel.java:86) ~[r2dbc-postgresql-0.8.8.RELEASE.jar:0.8.8.RELEASE]
at reactor.core.publisher.FluxCreate$BufferAsyncSink.drain(FluxCreate.java:793) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxCreate$BufferAsyncSink.next(FluxCreate.java:718) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxCreate$SerializedFluxSink.next(FluxCreate.java:154) ~[reactor-core-3.4.9.jar:3.4.9]
at io.r2dbc.postgresql.client.ReactorNettyClient$Conversation.emit(ReactorNettyClient.java:735) ~[r2dbc-postgresql-0.8.8.RELEASE.jar:0.8.8.RELEASE]
at io.r2dbc.postgresql.client.ReactorNettyClient$BackendMessageSubscriber.emit(ReactorNettyClient.java:986) ~[r2dbc-postgresql-0.8.8.RELEASE.jar:0.8.8.RELEASE]
at io.r2dbc.postgresql.client.ReactorNettyClient$BackendMessageSubscriber.onNext(ReactorNettyClient.java:860) ~[r2dbc-postgresql-0.8.8.RELEASE.jar:0.8.8.RELEASE]
at io.r2dbc.postgresql.client.ReactorNettyClient$BackendMessageSubscriber.onNext(ReactorNettyClient.java:767) ~[r2dbc-postgresql-0.8.8.RELEASE.jar:0.8.8.RELEASE]
at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:119) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxPeekFuseable$PeekConditionalSubscriber.onNext(FluxPeekFuseable.java:854) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onNext(FluxMap.java:220) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.core.publisher.FluxMap$MapConditionalSubscriber.onNext(FluxMap.java:220) ~[reactor-core-3.4.9.jar:3.4.9]
at reactor.netty.channel.FluxReceive.drainReceiver(FluxReceive.java:279) ~[reactor-netty-core-1.0.10.jar:1.0.10]
at reactor.netty.channel.FluxReceive.onInboundNext(FluxReceive.java:388) ~[reactor-netty-core-1.0.10.jar:1.0.10]
at reactor.netty.channel.ChannelOperations.onInboundNext(ChannelOperations.java:404) ~[reactor-netty-core-1.0.10.jar:1.0.10]
at reactor.netty.channel.ChannelOperationsHandler.channelRead(ChannelOperationsHandler.java:93) ~[reactor-netty-core-1.0.10.jar:1.0.10]
我认为我的问题的主要原因是隐藏在下一个跟踪块中:
at org.jooq.impl.R2DBC$R2DBCResultSet$DefaultRow.get(R2DBC.java:1110) ~[jooq-3.15.1.jar:na]
at org.jooq.impl.R2DBC$R2DBCResultSet.nullable(R2DBC.java:989) ~[jooq-3.15.1.jar:na]
at org.jooq.impl.R2DBC$R2DBCResultSet.nullable(R2DBC.java:985) ~[jooq-3.15.1.jar:na]
at org.jooq.impl.R2DBC$R2DBCResultSet.getString(R2DBC.java:1050) ~[jooq-3.15.1.jar:na]
at org.jooq.impl.DefaultBinding$DefaultEnumTypeBinding.get0(DefaultBinding.java:2560) ~[jooq-3.15.1.jar:na]
我的表中有一个枚举列,但它不可为null。
r2dbc-postgresql驱动程序有一个已知的限制,如果您事先手动注册枚举类型,它目前无法反序列化枚举类型:https://github.com/pgjdbc/r2dbc-postgresql/issues/429
这里有一些关于如何做到这一点的说明:https://github.com/pgjdbc/r2dbc-postgresql#postgres-enum-types
我试图实现一个简单的android应用程序,在这个应用程序中,我试图通过php站点检索数据库值,但是下面的代码在解析json数据时产生错误。 我的php文件编码json如下 Android类如下 最后是logcat输出 如何获得表的所需值 请帮忙。
问题内容: 我的项目有一个WCF,可以从数据库获取记录并以JSON格式返回,如下所示: 我也有一个Android应用程序来使用JSON,这是我的代码: 我在处设置了断点,并从中得到了以下消息: 我试图复制JSON字符串并粘贴到在线JSON解析器网站http://jsonviewer.stack.hu/上,它解析得很好。请帮我解决这个问题! 问题答案: 在您的json中,的值包含在其中,因此将其视为
这是控制器代码部分: 我收到这条消息: 出现错误(类型=错误请求,状态=400)。无法将类型[java.lang.String]的值转换为所需类型[java.util.Date];嵌套异常为org.springframework.core.convert.conversionfailedexception:无法将值“Wed Jun 08 00:00:00 WET 2016”从类型[java.lan
问题内容: 我有一个JSON文件,其中包含2个JSON数组:一个用于路线的数组,一个用于景点的数组。 一条路线应由用户导航到的多个景点组成。不幸的是我遇到了错误: JSONException:无法将类型为java.lang.String的值转换为JSONObject 这是我的变量和解析JSON文件的代码: Log.i(“ JSON Parser”,json); 告诉我在生成的字符串的开头有一个奇怪
我有两个实体,它们使用一个主键互相引用,主键是一个实体的整数。我不确定我做这件事的方式是否正确。 下面是引用主键id为int的实体 下面是我们从上面的实体中将外键设置为Kmichango kandaMchango的实体。 这里是表单的一部分,我在这里提交了用户在jumuiya_michango_form.html中提供的数据 下面是我的控制器中用于链接到表单和发布数据的两个方法 在我提交表单后,我
我正试图通过提供JSON格式的所需请求来使用postman来访问一个服务: 邮递员屏幕 但我得到了一个错误: “无法将类型”java.lang.String“的值转换为所需的类型”SampleRequestObject“;嵌套异常为java.lang.IllegalStateException:无法将类型[java.lang.String]的值转换为所需类型“ 控制器 SampleRequestO