简体   繁体   中英

Problem with create temporary table mysql in java program

I'm new on java programming.

I've a problem with creation a temporary table in Java..

Database db = new Database();

String query="create temporary table sconti (codcon int(11) not null, " + 
            " sigcos char(4) not null, codgru char(4) not null, codsgr char(4) not null, " + 
            " desgru char(100) not null, dessgr char(100) not null, sconto1 double(16,4) not null, " + 
            " sconto2 double(16,4) not null,sconto3 double(16,4) not null,primary key(codcon,sigcos,codgru,codsgr));";

db.executequery(query);

With first instruction I connect to the database then do the query with executequery

the debug error is:

Field 'codgru' doesn't have a default value

If you set a column as not null , you have to set a Default value. This is missing for some columns in query. So remove not null or add a default value. https://dev.mysql.com/doc/refman/8.0/en/create-table.html

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