问题标签 [simplejdbcinsert]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
2 回答
1461 浏览

java - 用 simpleJdbcInsert 替换重复项

我在 Mysql Server 5.5 的服务器端使用 tomcat。

我使用 Spring 框架进行数据库连接。

我希望能够使用 simpleJdbcInsert 向表中插入一行。如果插入因重复而失败,我希望它替换重复的行。

有没有办法做到这一点 simpleJdbcInsert 或者我应该只使用 jdbcTemplate 并使用“ON DUPLICATE”语句创建我的查询?

谢谢

0 投票
4 回答
364 浏览

java - update automatically after insert is successful in java

i need to update a table automatically after the insert of another table is successful. i am using prepared statement to do this, and tried couple of ways to do but dint work out. can some one please help me out on this. the code is given following

for me it execution get stucks after p.executeUpdate();

0 投票
5 回答
11124 浏览

spring - 用于更新的 SimpleJdbcInsert 等效项

我正在使用 Spring 的 SimpleJdbcInsert 类来创建实体 - 例如:

是否有与此类等效的更新?例如,假设我们正在处理单列主键,类似下面的内容将是一个方便的界面:

Spring 是否在某个地方开箱即用地提供了此功能?

谢谢杰

0 投票
2 回答
939 浏览

java - SimpleJdbcInsert - 不在默认模式的表中插入数据

我正在为使用 Spring 的 SimpleJdbcInsert 的代码而苦苦挣扎。

当我在默认模式为“PUBLIC”的连接上使用它时,这很好用,因为我没有设置任何模式。但是,当我添加一些模式,然后将 MY_SCHEMA1 作为连接的默认模式时,这不再起作用。它根本找不到表 MY_TABLE。

如果我将 .withSchemaName(MY_SCHEMA1) 添加到 SimpleJdbcInsert,它就会开始工作。但是,我没有那个选项。

请帮忙。

注意:我在 H2 和 DB2 上使用它。

0 投票
1 回答
748 浏览

spring - 使用 simplejdbcinsert 语句时,列会重复

我正在使用 SimpleJdbcInsert 存储记录,当我运行以下代码时,它给了我一个异常。当我看到日志时,我发现 spring 正在生成一个将所有参数加倍的插入查询。请说问题出在哪里。

0 投票
0 回答
213 浏览

java - SimpleJdbcInsert 到名称中带有点的表

我正在尝试将 SimpleJdbcInsert 用于名称中恰好有一个点字符的表,其中 dbo 作为默认模式。我传入要插入的键值映射。

出现以下异常:

PreparedStatementCallback; bad SQL grammar [INSERT INTO Trades.Transaction (Uid, StreamId, Version, ValidFrom, ValidTo, IsLatest, Direction, Quantity, Notional, TradeDate, Status, Action, SettlementAmount, SettlementCurrency, AccruedInterest, BookingAccountType, BookingAccountUid, BookingAccountName, BookingAccountLegalEntityId, BookingAccountLegalEntityShortName, BookingAccountRepUid, BookingAccountRepName, BookingAccountFacilitatorUid, BookingAccountFacilitatorName, BookingAccountFacilitatorTeamCode, ContraAccountType, ContraAccountUid, ContraAccountName, ContraAccountLegalEntityId, ContraAccountLegalEntityShortName, ContraAccountRepUid, ContraAccountRepName, ContraAccountFacilitatorUid, ContraAccountFacilitatorName, ContraAccountFacilitatorTeamCode, FacingAccountType, FacingAccountUid, FacingAccountName, FacingAccountLegalEntityId, FacingAccountLegalEntityShortName, FacingAccountRepUid, FacingAccountRepName, FacingAccountFacilitatorUid, FacingAccountFacilitatorName, FacingAccountFacilitatorTeamCode, OrigSystemIsElectronicChannel, OrigSystem, OrigSystemUid, OrigSystemStatus, OrigSystemType, OrigSystemVersion, OrigSystemErrors, DestSystemUid, DestSystem, DestSystemStatus, DestSystemType, DestSystemVersion, DestSystemErrors, StpSystemUid, StpSystem, StpSystemStatus, StpSystemType, StpSystemVersion, StpSystemErrors, GatewaySystem, GatewaySystemStatus, GatewaySystemType, GatewaySystemVersion, GatewaySystemErrors, SettlementSystemUid, SettlementSystemName, SettlementSystemStatus, SettlementSystemType, SettlementSystemVersion, SettlementSystemErrors, TransactionType, Price, Obligor, Receiver, QuoteDate, EffectiveDate, MaturityDate, UnitSize, MatchedStatus, MatchedTradeId, InstrumentDescription, BookingFacilitatorTeamCode, FxClientRate, Principal, AccruedDays, SalesCommissionCode, SalesCommissionAmount, SalesCommissionRate, SalesCommissionCcy, BrokerCommissionCode, BrokerCommissionAmount, BrokerCommissionRate, BrokerCommissionCcy, MarkupCommissionCode, MarkupCommissionAmount, MarkupCommissionRate, MarkupCommissionCcy, AddOnCommissionCode, AddOnCommissionAmount, AddOnCommissionRate, AddOnCommissionCcy, PhoneConfirmInd, PhoneConfirmBy, PhoneConfirmOn, SalesManagerReview, SalesManagerReviewComments, SalesManagerReviewTime, SalesManagerReviewIndicator, TradeManagerReview, TradeManagerReviewComments, TradeManagerReviewTime, TradeManagerReviewIndicator, EnteredOn, UpdatedOn, EnteredBy, GatewaySystemUid, OrigSystemNote1, OrigSystemNote2, OrigSystemNote3, DestSystemNote1, DestSystemNote2, DestSystemNote3, GatewayAllocFlag, QuotedAmount, LastModifiedBy, OrigTransactionId, OrigMarkitWireId, ContraAccountGlobalBook, BookingAccountGlobalBook, FXSettleAmount, SettlementLocation, AssignmentFeeCd, AssignmentFeeDesc, RiskFlagCd, RiskFlagDesc, FormPurchaseCd, FormPurchaseDesc, AccruedInterestCd, AccruedInterestDesc, EcnName, EcnId, ContraAccountLocation, BookingAccountLocation, isSuppressTrade, ContraAccountTradingSystem, BookingAccountTradingSystem, isAmend, RetailCommissionCode, RetailCommissionAmount, RetailCommissionRate, RetailCommissionCcy, ContraAccountADPAccountNo, AsOfTime, ClientCommission, MarketRate, DayCount, ExecutionStatus, LinkStreamId, Spread, RfqId, isWashGen, FxRateCurrencyPair, FxRateCalcMethod, isApprovedForNewIssueAllocation, TransactionReservationId, isEligibleForTradeSync) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)]; nested exception is java.sql.SQLException: Incorrect syntax near the keyword 'Transaction'.

我相信我需要一种Trade.Transaction用 [ ] 字符包围的方法,以便将其解释为完整的表名而不是schema.tableName. 但是,如果我在表名中指定这些,如下所示

发生 Spring 异常,说明它找不到元数据,因此无法找到列名来生成插入语句。

有谁知道我该如何解决这个问题?

谢谢

0 投票
1 回答
4243 浏览

spring - Spring SimpleJdbcInsert 与 JdbcTemplate

我有一个要求,我必须在数据库中插入一行并取回密钥(身份)。我想为此使用 SimpleJdbcInsert。我将 Object 传递JdbcTemplate给我的SimpleJdbcInsert和正在执行的方法executeAndReturnKey()

同样可以使用通过设置而不是参数映射的update()方法来完成。JdbcTemplatePreparedStatement

我只想知道 JdbcTemplate 在性能方面是否更好,我应该在 SimpleJdbcInsert 上使用它吗?如果是这样,那么它卓越性能的原因是什么?

注意:我插入的不是一批记录,而是一条记录。

谢谢

0 投票
1 回答
1306 浏览

java - How to insert a row to DB in spring, using only auto-generated values, and return an ID?

I use spring framework, and would like to insert a row to DB in order to have its ID, which is needed for further processing. Inserting query is given below, it's a simple query, without parameters. But it's even worse, cause how to construct working call using executeAndReturnKey from SimpleJdbcInsert? This is an SQL query for insert. But I don't know whether it is possible to use it within simpleJdbcInsert instance.

I tried

It doesn't work, the thing is, they want all parameters for the table, but I dont want any of them, I want to insert only auto-generated: id_import_run (primary key) and create_date. As a result I want to have the inserted ID in a variable. How would you do that?

EDIT Such an approach works fine.

0 投票
2 回答
1451 浏览

oracle - 在 SimpleJdbcInsert 对象中指定 Oracle 序列以从 Oracle 序列生成密钥

我使用 SimpleJdbcInsert 作为,

但它只对 ID 列抛出错误,其他列工作正常,我通过注释掉 ID 列确认。

我检查了我的 Oracle 序列,它工作正常。我检查了许多博客,但找不到使用 Oracle 序列和 SimpleJdbcInsert 的合适博客。

0 投票
0 回答
361 浏览

java - 布尔字段的 SimpleJdbcInsert 问题

我正在尝试使用spring API向数据库插入一条记录SimpleJdbcInsert......但是,当模型对象携带Boolean变量时它的创建问题......如果我将Boolean变量设置为true,它实际上将NULL值插入数据库......我的代码就像下面...请帮助我..提前非常感谢..