简体   繁体   English

使用Jooq插入查询是否可能?

[英]insert query using Jooq is it possible?

I have insert statement in a string value now i want to change that into Jooq and excute the jooq on the DB is it possible ? 我现在在字符串值中插入语句我想将其更改为Jooq并在DB上执行jooq是否可能? or am i over expecting ? 还是我过度期待?

My Insert Query : 我的插入查询:

INSERT INTO ANTIQUES (ID,TYPE,NAME,PRICE) VALUES (21, 01, 'Ottoman', 200.00);

Here are some details missing in the above answer, and also on JOOQ's website. 以下是上述答案中缺少的一些细节,以及JOOQ网站上的一些细节。 create.insertInto(Antiques.ANTIQUES, Antiques.ANTIQUES.ID, Antiques.ANTIQUES.TYPE, Antiques.ANTIQUES.NAME,Antiques.ANTIQUES.PRICE) .values(21, 01, 'Ottoman', 200.00).execute();

  1. Here in Antiques.ANTIQUES , "Antiques" is the name of the class in tables package and ANTIQUES is the static final object created in the same class for reference. Antiques.ANTIQUES ,“Antiques”是表包中类的名称,ANTIQUES是在同一类中创建的静态最终对象以供参考。
  2. In the same way you will call your column names which are created in the same Antiques class for reference as Antiques.ANTIQUES.TYPE . 以同样的方式,您将调用在同一个Antiques类中创建的列名,以作为Antiques.ANTIQUES.TYPE参考。
  3. The query will not be effective if the execute method is not applied. 如果未应用execute方法,则查询将无效。

Yes, you can do this. 是的,你可以这样做。 It should be similiar with the following code. 它应该类似于以下代码。

create.insertInto(ANTIQUES,
    ANTIQUES.ID, ANTIQUES.TYPE, ANTIQUES.NAME, ANTIQUES.PRICE)
    .values(21, 01, 'Ottoman', 200.00);

Please check the tutorial and document. 请查看教程和文档。

  1. The INSERT statement INSERT语句
  2. Tutorial: Getting started with jOOQ 教程:jOOQ入门

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM