Asked
5 years, 7 months ago
Viewed
3k times
I have three files:
-
Message.java
public class Message { @Id @GeneratedValue private Long id; private String text; public String getText() { return text; } public void setText(String text) { this.text = text; } } -
persistence.xml
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.1" xmlns="http://xmlns.jcp.org/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
http://xmlns.jcp.org/xml/ns/persistence_2_1.xsd">
<persistence-unit name="HelloWorldPU">
<!-- <jta-data-source>myDB</jta-data-source> -->
<class>org.jpwh.model.helloworld.Message</class>
<exclude-unlisted-classes>true</exclude-unlisted-classes>
<properties>
<property name="javax.persistence.schema-generation.database.action" value="drop-and-create" />
<property name="hibernate.format_sql" value="true" />
<property name="hibernate.use_sql_comments" value="true" />
<property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
<property name="javax.persistence.jdbc.user" value="laki" />
<property name="javax.persistence.jdbc.password" value="laki" />
<property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/nekretnine?autoreconnect=true" />
<property name="hibernate.dialect" value="org.hibernate.dialect.HSQLDialect" />
<property name="hibernate.max_fetch_depth" value="3" />
</properties>
</persistence-unit>
</persistence>
-
Main.java
public class Main { public static void main(String[] args) { EntityManagerFactory emf = Persistence.createEntityManagerFactory("HelloWorldPU"); EntityManager em = emf.createEntityManager(); Message message = new Message(); message.setText("kurcina"); em.persist(message); } }
When I execute Main class table Message is created in DB, but I get these exceptions
WARN: GenerationTarget encountered exception accepting command : Error executing DDL via JDBC Statement
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:440)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:424)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:290)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:155)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
at org.hibernate.internal.SessionFactoryImpl.<init>(SessionFactoryImpl.java:309)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:452)
at org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl.build(EntityManagerFactoryBuilderImpl.java:889)
at org.hibernate.jpa.HibernatePersistenceProvider.createEntityManagerFactory(HibernatePersistenceProvider.java:58)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:55)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:39)
at tutorial.Main.main(Main.java:19)
Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'sequence hibernate_sequence start with 1 increment by 1' at line 1
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:536)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:115)
at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1983)
at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1936)
at com.mysql.cj.jdbc.StatementImpl.executeInternal(StatementImpl.java:891)
at com.mysql.cj.jdbc.StatementImpl.execute(StatementImpl.java:795)
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:54)
... 15 more
Jun 30, 2017 5:51:41 PM org.hibernate.tool.schema.internal.SchemaCreatorImpl applyImportSources
INFO: HHH000476: Executing import script 'org.hibernate.tool.schema.internal.exec.ScriptSourceInputNonExistentImpl@4566d049'
Jun 30, 2017 5:51:41 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 1064, SQLState: 42000
Jun 30, 2017 5:51:41 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'value for hibernate_sequence' at line 1
Exception in thread "main" javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:147)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:155)
at org.hibernate.internal.ExceptionConverterImpl.convert(ExceptionConverterImpl.java:162)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:787)
at org.hibernate.internal.SessionImpl.persist(SessionImpl.java:765)
at tutorial.Main.main(Main.java:25)
Caused by: org.hibernate.exception.SQLGrammarException: could not extract ResultSet
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:63)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:80)
at org.hibernate.id.enhanced.SequenceStructure$1.getNextValue(SequenceStructure.java:95)
at org.hibernate.id.enhanced.NoopOptimizer.generate(NoopOptimizer.java:40)
at org.hibernate.id.enhanced.SequenceStyleGenerator.generate(SequenceStyleGenerator.java:432)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:105)
at org.hibernate.jpa.event.internal.core.JpaPersistEventListener.saveWithGeneratedId(JpaPersistEventListener.java:67)
at org.hibernate.event.internal.DefaultPersistEventListener.entityIsTransient(DefaultPersistEventListener.java:189)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:132)
at org.hibernate.event.internal.DefaultPersistEventListener.onPersist(DefaultPersistEventListener.java:58)
at org.hibernate.internal.SessionImpl.firePersist(SessionImpl.java:780)
... 2 more
Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'value for hibernate_sequence' at line 1
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:536)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:115)
at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:1983)
at com.mysql.cj.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1826)
at com.mysql.cj.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1923)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:71)
... 11 more
Any ideas please? From what I found this error with MariaDB is being reported when there is SQL query written by user, but I don’t have any queries.
asked Jun 30, 2017 at 16:21
4
You’re using the dialect of the HSQLDB database, but your database is MariaDB/MySQL.
Use the right dialect.
You told Hibernate to drop and create the schema for you, so it does that. Creating the schema obviously requires executing SQL queries.
answered Jun 30, 2017 at 16:33
JB NizetJB Nizet
671k88 gold badges1207 silver badges1242 bronze badges
I’m learning Hibernate, and during simple demo application, I encounter problem, I can’t overcame. There are only two tables, two entity classes and main app. Project is in maven.
Github: github.com/fangirsan/maruszka.git
Batch.class:
package com.maruszka.entity;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name="batch")
public class Batch {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
private int id;
@Column(name="batch_number")
private int batchNumber;
@Column(name="batch_style")
private String batchStyle;
@Column(name="batch_name")
private String batchName;
@Column(name="batch_creation_date", columnDefinition="DATE")
@Temporal(TemporalType.TIMESTAMP)
private Date batchCreationDate;
@ManyToMany(fetch=FetchType.LAZY,
cascade= {CascadeType.PERSIST, CascadeType.MERGE,
CascadeType.DETACH, CascadeType.REFRESH})
@JoinTable(
name="batch_malt",
joinColumns=@JoinColumn(name="batch_id"),
inverseJoinColumns=@JoinColumn(name="malt_id")
)
private List<Malt> malts;
public Batch() {
}
public Batch(int batchNumber, String batchStyle, String batchName, Date batchCreationDate) {
this.batchNumber = batchNumber;
this.batchStyle = batchStyle;
this.batchName = batchName;
this.batchCreationDate = batchCreationDate;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getBatchNumber() {
return batchNumber;
}
public void setBatchNumber(int batchNumber) {
this.batchNumber = batchNumber;
}
public String getBatchStyle() {
return batchStyle;
}
public void setBatchStyle(String batchStyle) {
this.batchStyle = batchStyle;
}
public String getBatchName() {
return batchName;
}
public void setBatchName(String batchName) {
this.batchName = batchName;
}
public Date getBatchCreationDate() {
return batchCreationDate;
}
public void setBatchCreationDate(Date batchCreationDate) {
this.batchCreationDate = batchCreationDate;
}
public List<Malt> getMalts() {
return malts;
}
public void setMalts(List<Malt> malts) {
this.malts = malts;
}
@Override
public String toString() {
return "Batch [id=" + id + ", batchNumber=" + batchNumber + ", batchStyle=" + batchStyle + ", batchName="
+ batchName + ", batchCreationDate=" + batchCreationDate + ", malts=" + malts + "]";
}
// add a convenience method
public void addMalt(Malt theMalt) {
if (malts == null) {
malts = new ArrayList<>();
}
malts.add(theMalt);
}
}
Malt.class
package com.maruszka.entity;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
@Entity
@Table(name="malt")
public class Malt {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
@Column(name="id")
private int id;
@Column(name="malt_name")
private String maltName;
@Column(name="malt_manufacturer")
private String maltManufacturer;
@Column(name="filling")
private int filling;
@Column(name="ebc")
private int ebc;
@Column(name="usage")
private String usage;
@ManyToMany(fetch=FetchType.LAZY,
cascade= {CascadeType.PERSIST, CascadeType.MERGE,
CascadeType.DETACH, CascadeType.REFRESH})
@JoinTable(
name="batch_malt",
joinColumns=@JoinColumn(name="malt_id"),
inverseJoinColumns=@JoinColumn(name="batch_id")
)
private List<Batch> batches;
public Malt() {
}
public Malt(String maltName, String maltManufacturer, int filling, int ebc, String usage) {
this.maltName = maltName;
this.maltManufacturer = maltManufacturer;
this.filling = filling;
this.ebc = ebc;
this.usage = usage;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getMaltName() {
return maltName;
}
public void setMaltName(String maltName) {
this.maltName = maltName;
}
public String getMaltManufacturer() {
return maltManufacturer;
}
public void setMaltManufacturer(String maltManufacturer) {
this.maltManufacturer = maltManufacturer;
}
public int getFilling() {
return filling;
}
public void setFilling(int filling) {
this.filling = filling;
}
public int getEbc() {
return ebc;
}
public void setEbc(int ebc) {
this.ebc = ebc;
}
public String getUsage() {
return usage;
}
public void setUsage(String usage) {
this.usage = usage;
}
public List<Batch> getBatches() {
return batches;
}
public void setBatches(List<Batch> batches) {
this.batches = batches;
}
@Override
public String toString() {
return "Malt [id=" + id + ", maltName=" + maltName + ", maltManufacturer=" + maltManufacturer + ", filling="
+ filling + ", ebc=" + ebc + ", usage=" + usage + ", batches=" + batches + "]";
}
}
CreateBatchAndMalt.class (main):
package com.maruszka.test;
import java.util.Date;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import com.maruszka.entity.Malt;
import com.maruszka.entity.Batch;
public class CreateBatchAndMalt {
public static void main(String[] args) {
// create session factory
SessionFactory factory = new Configuration()
.configure("hibernate.cfg.xml")
.addAnnotatedClass(Batch.class)
.addAnnotatedClass(Malt.class)
.buildSessionFactory();
// create session
Session session = factory.getCurrentSession();
try {
// start a transaction
session.beginTransaction();
// create a malt
Malt tempMalt = new Malt("Carafa (R) typ I", "Weyerman", 10, 900, "Stout, Porter, Schwarzbier");
// save the malt
System.out.println("nSaving the malt ...");
session.save(tempMalt);
System.out.println("Saved the malt: " + tempMalt);
// create the batch
Date now = new Date();
Batch tempBatch = new Batch(2, "Mild", "Szatan", now);
// add malt to the batch
tempBatch.addMalt(tempMalt);
// save the batch
System.out.println("nSaving batch ...");
session.save(tempBatch);
System.out.println("Saved batch: " + tempBatch.getMalts());
// commit transaction
session.getTransaction().commit();
System.out.println("Done!");
}
finally {
// close session
session.close();
factory.close();
}
}
}
pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.maruszka</groupId>
<artifactId>maruszka</artifactId>
<packaging>war</packaging>
<version>1.0</version>
<name>maruszka Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<springframework.version>5.0.2.RELEASE</springframework.version>
<springsecurity.version>5.0.1.RELEASE</springsecurity.version>
<hibernate.version>5.3.1.Final</hibernate.version>
<!-- 5.2.12.Final -->
<mysql.connector.version>5.1.38</mysql.connector.version>
<c3po.version>0.9.5.2</c3po.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- Add support for JUnit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- Spring MVC support -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springframework.version}</version>
</dependency>
<!-- Add support for Spring Tags -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-taglibs</artifactId>
<version>${springsecurity.version}</version>
</dependency>
<!-- Hibernate Core -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate.version}</version>
</dependency>
<!-- Hibernate Validator -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.4.Final</version>
</dependency>
<!-- Add MySQL and C3P0 support -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.connector.version}</version>
</dependency>
<!-- dependency>
<groupId>com.mchange</groupId>
<artifactId>c3p0</artifactId>
<version>0.9.5.2</version>
</dependency-->
</dependencies>
<build>
<!-- TO DO: Add support for Maven WAR Plugin -->
<finalName>maruszka</finalName>
<pluginManagement>
<plugins>
<plugin>
<!-- Add Maven coordinates for: maven-war-plugin -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
hibernate.cfg.xml (in maruszkasrcmainresourceshibernate.cfg.xml):
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- JDBC Database connection settings -->
<property name="connection.driver_class">com.mysql.cj.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/maruszka?serverTimezone=UTC</property>
<!-- &useSSL=false -->
<property name="connection.username">***</property>
<property name="connection.password">***</property>
<!-- JDBC connection pool settings ... using built-in test pool -->
<property name="connection.pool_size">1</property>
<!-- Select our SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<!-- Echo the SQL to stdout -->
<property name="show_sql">false</property>
<!-- Set the current session context -->
<property name="current_session_context_class">thread</property>
</session-factory>
</hibernate-configuration>
DB script:
CREATE DATABASE IF NOT EXISTS `maruszka`;
USE `maruszka`;
SET FOREIGN_KEY_CHECKS=0;
-- batch
DROP TABLE IF EXISTS `batch`;
CREATE TABLE `batch` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`batch_number` int(3) NOT NULL,
`batch_style` varchar(45) DEFAULT NULL,
`batch_name` varchar(45) DEFAULT NULL,
`batch_creation_date` DATE,
PRIMARY KEY (`id`),
UNIQUE KEY(`batch_number`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
LOCK TABLE `batch` WRITE;
INSERT INTO `batch` VALUES
(1, 1, 'Stout', 'Happy Stout', '2018-06-06');
UNLOCK TABLES;
-- malt
DROP TABLE IF EXISTS `malt`;
CREATE TABLE `malt` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`malt_name` varchar(45) DEFAULT NULL,
`malt_manufacturer` varchar(45) DEFAULT NULL,
`filling` int(3) DEFAULT NULL,
`ebc` int(3) DEFAULT NULL,
`usage` varchar(254) DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY(`malt_name`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;
LOCK TABLES `malt` WRITE;
INSERT INTO `malt` VALUES
(1, 'Pale Ale', 'Malteurop', 100, 6, 'All');
UNLOCK TABLES;
-- join table for batch - malt
DROP TABLE IF EXISTS `batch-malt`;
CREATE TABLE `batch-malt` (
`batch_id` int(11) NOT NULL,
`malt_id` int(11) NOT NULL,
PRIMARY KEY (`batch_id`, `malt_id`),
-- fk_[referencing table name]_[referenced table name]_[referencing field name]
CONSTRAINT `FK_BATCH_MALT_ID` FOREIGN KEY (`malt_id`)
REFERENCES `malt` (`id`)
ON DELETE NO ACTION ON UPDATE NO ACTION,
CONSTRAINT `FK_MALT_BATCH_ID` FOREIGN KEY (`batch_id`)
REFERENCES `batch` (`id`)
ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
SET FOREIGN_KEY_CHECKS=1;
When using mysql connector in version 8.0.11:
cze 06, 2018 9:33:53 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {5.3.1.Final}
cze 06, 2018 9:33:53 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
cze 06, 2018 9:33:53 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {5.0.3.Final}
cze 06, 2018 9:33:53 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl configure
WARN: HHH10001002: Using Hibernate built-in connection pool (not for production use!)
cze 06, 2018 9:33:53 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001005: using driver [com.mysql.cj.jdbc.Driver] at URL [jdbc:mysql://localhost:3306/maruszka?serverTimezone=UTC]
cze 06, 2018 9:33:53 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001001: Connection properties: {user=root, password=****}
cze 06, 2018 9:33:53 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl buildCreator
INFO: HHH10001003: Autocommit mode: false
cze 06, 2018 9:33:53 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl$PooledConnections <init>
INFO: HHH000115: Hibernate connection pool size: 1 (min=1)
Wed Jun 06 21:33:53 CEST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
cze 06, 2018 9:33:53 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQLDialect
cze 06, 2018 9:33:54 PM org.hibernate.validator.internal.util.Version <clinit>
INFO: HV000001: Hibernate Validator 6.0.4.Final
Saving the malt ...
cze 06, 2018 9:33:54 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
WARN: SQL Error: 1064, SQLState: 42000
cze 06, 2018 9:33:54 PM org.hibernate.engine.jdbc.spi.SqlExceptionHelper logExceptions
ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'usage) values (900, 10, 'Weyerman', 'Carafa (R) typ I', 'Stout, Porter, Schwarzb' at line 1
cze 06, 2018 9:33:54 PM org.hibernate.engine.jdbc.connections.internal.DriverManagerConnectionProviderImpl stop
INFO: HHH10001008: Cleaning up connection pool [jdbc:mysql://localhost:3306/maruszka?serverTimezone=UTC]
Exception in thread "main" org.hibernate.exception.SQLGrammarException: could not execute statement
at org.hibernate.exception.internal.SQLExceptionTypeDelegate.convert(SQLExceptionTypeDelegate.java:63)
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:42)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:111)
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:97)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:178)
at org.hibernate.dialect.identity.GetGeneratedKeysDelegate.executeAndExtract(GetGeneratedKeysDelegate.java:57)
at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:42)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3037)
at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3628)
at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:81)
at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:645)
at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:282)
at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:263)
at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:317)
at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:359)
at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:292)
at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:200)
at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:131)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java:192)
at org.hibernate.event.internal.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:38)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:177)
at org.hibernate.event.internal.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:32)
at org.hibernate.event.internal.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:73)
at org.hibernate.internal.SessionImpl.fireSave(SessionImpl.java:709)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:701)
at org.hibernate.internal.SessionImpl.save(SessionImpl.java:696)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.hibernate.context.internal.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:349)
at com.sun.proxy.$Proxy36.save(Unknown Source)
at com.maruszka.test.CreateBatchAndMalt.main(CreateBatchAndMalt.java:42)
Caused by: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'usage) values (900, 10, 'Weyerman', 'Carafa (R) typ I', 'Stout, Porter, Schwarzb' at line 1
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:118)
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:95)
at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:960)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1116)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1066)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1396)
at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:1051)
at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:175)
... 28 more
I’ve double check syntax, but can’t figure out wha is causing this:
ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'usage) values (900, 10, 'Weyerman', 'Carafa (R) typ I', 'Stout, Porter, Schwarzb' at line 1
Best regards
Hello,
I’m trying to persist two objects that present a many-to-many relation. When persisting them individually there are no problems, but when I include the references in both, I receive the expection I report below.
I double checked all the mapping and the code but there is something I must be missing — perhaps it’s a bit more conceptual?!?
Any suggestions or hints on the possible causes and solutions?
Thanks!
Dan
======================================
Hibernate version 3.3.1.GA
(mapping: )
Code:
<class name=»db.data.persistence.hibernate.Model» table=»MODELS»>
<id column=»ID» name=»id»>
<generator class=»increment»/>
</id>
<property column=»name» name=»name» type=»string»/>
<property column=»description» name=»description» type=»string»/>
<property column=»keywords» name=»keywords» type=»string»/>
<property column=»file» name=»file» type=»text»/>
<set name=»createdBy» table=»CREATE» lazy=»true» cascade=»save-update»>
<key column=»AUTHORID»/>
<many-to-many class=»db.data.persistence.hibernate.Author» column=»id»/>
</set>
</class>
<class name=»db.data.persistence.hibernate.Person» table=»PERSONS»>
<id column=»ID» name=»id»>
<generator class=»increment»/>
</id>
<property column=»givenName» name=»givenName» type=»string»/>
<property column=»familyName» name=»familyName» type=»string»/>
<property column=»email» name=»email» type=»string»/>
<property column=»affiliation» name=»affiliation» type=»string»/>
<!— User —>
<joined-subclass name=»db.data.persistence.hibernate.User» table=»USERS»>
<key column=»ID»/>
<property column=»accountName» name=»accountName» type=»string»/>
<property column=»password» name=»password» type=»string»/>
<property column=»enabled» name=»enabled» type=»boolean»/>
</joined-subclass>
<!— Author —>
<joined-subclass name=»db.data.persistence.hibernate.Author» table=»AUTHORS»>
<key column=»ID»/>
<property column=»otherInfo» name=»otherInfo» type=»string»/>
<set name=»created» table=»CREATE» lazy=»true» inverse=»true» cascade=»save-update»>
<key column=»MODELID»/>
<many-to-many class=»db.data.persistence.hibernate.Model» column=»ID»/>
</set>
</joined-subclass>
</class>
================================================================
CODE:
Code:
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
// find author
Integer authorId = 4; // la tabella authors ha un author con id == 4
Author author = (Author )session.load(Author.class, authorId);
System.out.println();
System.out.println(«Loaded author : «);
System.out.println(author.toString());
System.out.println();
System.out.println(«****************************************»);
// create model
Model model = new Model();
model.setDescription(«Description of the first model»);
model.setKeywords(«keywords»);
model.setName(«firstModel»);
model.setFile(«This text should be the xml file for this model»);
Integer modelId = (Integer )session.save(model);
// session.getTransaction().
model = (Model )session.load(Model.class, modelId);
// add author to model
model.getCreatedBy().add(author);
// add model to author
author.getCreated().add(model);
// persist author and model in the database
session.getTransaction().commit();
Stack trace:
SEVERE: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘CREATE createdby0_ left outer join AUTHORS author1_ on createdby0_.id=author1_.I’ at line 1
Exception in thread «main» org.hibernate.exception.SQLGrammarException: could not initialize a collection: [db.data.persistence.hibernate.Model.createdBy#1]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.loader.Loader.loadCollection(Loader.java:2001)
at org.hibernate.loader.collection.CollectionLoader.initialize(CollectionLoader.java:36)
at org.hibernate.persister.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:565)
at org.hibernate.event.def.DefaultInitializeCollectionEventListener.onInitializeCollection(DefaultInitializeCollectionEventListener.java:60)
at org.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:1716)
at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:344)
at org.hibernate.collection.PersistentSet.add(PersistentSet.java:189)
at db.persistence.hibernate.testing.TestWritingPersonUserAndAuthor.createAndStoreModel(TestWritingPersonUserAndAuthor.java:73)
at db.persistence.hibernate.testing.TestWritingPersonUserAndAuthor.main(TestWritingPersonUserAndAuthor.java:30)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘CREATE createdby0_ left outer join AUTHORS author1_ on createdby0_.id=author1_.I’ at line 1
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1030)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3491)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3423)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2542)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1734)
at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1885)
at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:186)
at org.hibernate.loader.Loader.getResultSet(Loader.java:1787)
at org.hibernate.loader.Loader.doQuery(Loader.java:674)
at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
at org.hibernate.loader.Loader.loadCollection(Loader.java:1994)
… 8 more
Java Result: 1
Database:
MySQL 5.0.67
This issue SyntaxErrorException for type MyISAM is occurred because of dialect selected for hibernate. Let’s consider my example and the issue occurred because of that.
Hibernate Configuration
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
As we know in the hibernate configured dialect decide the query generation as per database.
Query Generated
create table ADDRESS (
id integer not null auto_increment,
street_name varchar(255),
city_name varchar(255),
state_name varchar(255),
zipcode varchar(255),
primary key (id)
) type=MyISAM
Exception Stack Trace
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL via JDBC Statement
at org.hibernate.tool.schema.internal.exec.GenerationTargetToDatabase.accept(GenerationTargetToDatabase.java:67)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlString(SchemaCreatorImpl.java:440)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.applySqlStrings(SchemaCreatorImpl.java:424)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.createFromMetadata(SchemaCreatorImpl.java:315)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.performCreation(SchemaCreatorImpl.java:166)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:135)
at org.hibernate.tool.schema.internal.SchemaCreatorImpl.doCreation(SchemaCreatorImpl.java:121)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.performDatabaseAction(SchemaManagementToolCoordinator.java:155)
at org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator.process(SchemaManagementToolCoordinator.java:72)
at org.hibernate.internal.SessionFactoryImpl.(SessionFactoryImpl.java:309)
at org.hibernate.boot.internal.SessionFactoryBuilderImpl.build(SessionFactoryBuilderImpl.java:452)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:710)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:726)
at com.facingissuesonit.persistent.HibernateUtil.buildSessionFactory(HibernateUtil.java:13)
at com.facingissuesonit.persistent.HibernateUtil.(HibernateUtil.java:8)
at com.facingissuesonit.App.main(App.java:26)
Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=MyISAM' at line 8
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at com.mysql.jdbc.Util.getInstance(Util.java:381)
Solutions
As given above the problem is that the dialect org.hibernate.dialect.MySQLDialect is configured which is for MySQL 4.x or earlier version and we are pointing to MY SQL database with the newer version.
The query generated by dialect having to fragment TYPE=MyISAM that was deprecated in MySQL 4.0 and removed in 5.5. Earlier MySQL 4.x.x version use TYPE MyISAM engine used to store tables but in MySQL 5.x.x or later version MySQL is used ENGINE = MyISAM to store tables. e.g. thats make difference while hibernate generates queries.
As per the database configured for MySQL, we should use other dialects as per database configured. Here is the complete list of Hibernate dialects as per databases:
Hibernate: SQL Dialects List
For Example:
In MySQL <= 4.x.x use dialects as below
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
In MySQL>=5.x.x. use dialects as below
<property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
This is the issue I am trying to fix since hours, almost a day. I am unable to get an understanding of what might be wrong.
I have a SQL table notification
I am trying to persist a java object via hibernate
public void persistNotification(Notification notify){
sessionFactory.getCurrentSession().save(notify);
}
notify object passed to the method looks fine to me with all the values
Notification [notificationId=null, notificationMessage=ethan is now following you, notificationType=follow, notificationRead=false, actor=ethan, subject=diggle, notificationCreationTime=2015-12-09T19:13:23.002, userId=1]
But I am encountering a SyntaxErrorException.
2015-12-09 18:52:05.0550 DEBUG http-bio-8080-exec-10 org.hibernate.SQL – insert into notification (actor, creation_time, notification, read, type, subject, user_id) values (?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into notification (actor, creation_time, notification, read, type, subject, user_id) values (?, ?, ?, ?, ?, ?, ?)
2015-12-09 18:52:05.0579 DEBUG http-bio-8080-exec-10 org.hibernate.engine.jdbc.spi.SqlExceptionHelper – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read, type, subject, user_id) values ('ethan', '2015-12-09 18:51:54', 'ethan is ' at line 1 [n/a]
com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read, type, subject, user_id) values ('ethan', '2015-12-09 18:51:54', 'ethan is ' at line 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2941)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1623)
2015-12-09 19:00:08.0027 DEBUG http-bio-8080-exec-10 org.springframework.web.servlet.mvc.support.DefaultHandlerExceptionResolver – Resolving exception from handler [public org.springframework.http.ResponseEntity<java.lang.String> com.mycricket.controller.UserController.followUnfollowUser(java.lang.String)]: org.hibernate.exception.SQLGrammarException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read, type, subject, user_id) values ('ethan', '2015-12-09 19:00:07', 'ethan is ' at line 1
2015-12-09 19:00:08.0028 DEBUG http-bio-8080-exec-10 org.springframework.web.servlet.DispatcherServlet – Could not complete request
org.hibernate.exception.SQLGrammarException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'read, type, subject, user_id) values ('ethan', '2015-12-09 19:00:07', 'ethan is ' at line 1
at org.hibernate.exception.internal.SQLStateConversionDelegate.convert(SQLStateConversionDelegate.java:122)
Can anyone help me out what might be the issue? Any clue, guesses would be appreciated.
I also dropped & recreated the table but no luck. I don’t I am using any reserved SQL words.
Posted on
2018-03-12
If you see following error, it could just be, that you use one of the MySQL reserved words.
ERROR 1064 (42000) at line: You have an error in your SQL syntax
Hibernate Example
1 |
@Entity |
The example contains a variable called “create” which is reserved by MySQL and can not be used.
Please be aware that MySQL have a lot of those:
| Reserved Words | ||
|---|---|---|
| ACCESSIBLE | ADD | ALL |
| ALTER | ANALYZE | AND |
| AS | ASC | ASENSITIVE |
| BEFORE | BETWEEN | BIGINT |
| BINARY | BLOB | BOTH |
| BY | CALL | CASCADE |
| CASE | CHANGE | CHAR |
| CHARACTER | CHECK | COLLATE |
| COLUMN | CONDITION | CONSTRAINT |
| CONTINUE | CONVERT | CREATE |
| CROSS | CURRENT_DATE | CURRENT_TIME |
| CURRENT_TIMESTAMP | CURRENT_USER | CURSOR |
| DATABASE | DATABASES | DAY_HOUR |
| DAY_MICROSECOND | DAY_MINUTE | DAY_SECOND |
| DEC | DECIMAL | DECLARE |
| DEFAULT | DELAYED | DELETE |
| DESC | DESCRIBE | DETERMINISTIC |
| DISTINCT | DISTINCTROW | DIV |
| DOUBLE | DROP | DUAL |
| EACH | ELSE | ELSEIF |
| ENCLOSED | ESCAPED | EXISTS |
| EXIT | EXPLAIN | FALSE |
| FETCH | FLOAT | FLOAT4 |
| FLOAT8 | FOR | FORCE |
| FOREIGN | FROM | FULLTEXT |
| GRANT | GROUP | HAVING |
| HIGH_PRIORITY | HOUR_MICROSECOND | HOUR_MINUTE |
| HOUR_SECOND | IF | IGNORE |
| IN | INDEX | INFILE |
| INNER | INOUT | INSENSITIVE |
| INSERT | INT | INT1 |
| INT2 | INT3 | INT4 |
| INT8 | INTEGER | INTERVAL |
| INTO | IS | ITERATE |
| JOIN | KEY | KEYS |
| KILL | LEADING | LEAVE |
| LEFT | LIKE | LIMIT |
| LINEAR | LINES | LOAD |
| LOCALTIME | LOCALTIMESTAMP | LOCK |
| LONG | LONGBLOB | LONGTEXT |
| LOOP | LOW_PRIORITY | MASTER_SSL_VERIFY_SERVER_CERT |
| MATCH | MAXVALUE | MEDIUMBLOB |
| MEDIUMINT | MEDIUMTEXT | MIDDLEINT |
| MINUTE_MICROSECOND | MINUTE_SECOND | MOD |
| MODIFIES | NATURAL | NOT |
| NO_WRITE_TO_BINLOG | NULL | NUMERIC |
| ON | OPTIMIZE | OPTION |
| OPTIONALLY | OR | ORDER |
| OUT | OUTER | OUTFILE |
| PRECISION | PRIMARY | PROCEDURE |
| PURGE | RANGE | READ |
| READS | READ_WRITE | REAL |
| REFERENCES | REGEXP | RELEASE |
| RENAME | REPEAT | REPLACE |
| REQUIRE | RESIGNAL | RESTRICT |
| RETURN | REVOKE | RIGHT |
| RLIKE | SCHEMA | SCHEMAS |
| SECOND_MICROSECOND | SELECT | SENSITIVE |
| SEPARATOR | SET | SHOW |
| SIGNAL | SMALLINT | SPATIAL |
| SPECIFIC | SQL | SQLEXCEPTION |
| SQLSTATE | SQLWARNING | SQL_BIG_RESULT |
| SQL_CALC_FOUND_ROWS | SQL_SMALL_RESULT | SSL |
| STARTING | STRAIGHT_JOIN | TABLE |
| TERMINATED | THEN | TINYBLOB |
| TINYINT | TINYTEXT | TO |
| TRAILING | TRIGGER | TRUE |
| UNDO | UNION | UNIQUE |
| UNLOCK | UNSIGNED | UPDATE |
| USAGE | USE | USING |
| UTC_DATE | UTC_TIME | UTC_TIMESTAMP |
| VALUES | VARBINARY | VARCHAR |
| VARCHARACTER | VARYING | WHEN |
| WHERE | WHILE | WITH |
| WRITE | XOR | YEAR_MONTH |
| ZEROFILL |


