简体   繁体   中英

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 ? 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. 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.
  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 .
  3. The query will not be effective if the execute method is not applied.

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
  2. Tutorial: Getting started with jOOQ

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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