Exception when attempting to create the jdbc tables - amazon-aurora

When connecting to Amazon RDS MySQL Aurora the lagom service throws an exception when attempting to create the jdbc tables
2018-01-16T00:11:32.891Z [[31merror[0m] akka.actor.OneForOneStrategy
[sourceThread=userservice-v1-akka.actor.default-dispatcher-18, akkaTimestamp=
00:11:32.877UTC, akkaSource=akka://userservice-v1/user/slickOffsetStorePrepare-singleton/singleton/slickOffsetStorePrepare,
sourceActorSystem=userservice-v1] - 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_side_offsets" ("read_side_id" VARCHAR(255) NOT NULL,"tag" VARCHAR(255) NOT' at line 1 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 '"read_side_offsets" ("read_side_id" VARCHAR(255) NOT NULL,"tag" VARCHAR(255) NOT' at line 1
2018-01-16T00:11:32.896Z [[31merror[0m] akka.actor.OneForOneStrategy
[sourceThread=userservice-v1-akka.actor.default-dispatcher-20, akkaTimestamp=
00:11:32.885UTC, akkaSource=akka://userservice-v1/user/jdbcCreateTables-singleton/singleton/jdbcCreateTables,
sourceActorSystem=userservice-v1] - 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
'"journal" ("ordering" BIGINT AUTO_INCREMENT NOT NULL,"deleted" BOOLEAN DEFAULT f'
at line 1 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 '"journal" ("ordering" BIGINT
AUTO_INCREMENT NOT NULL,"deleted" BOOLEAN DEFAULT f' at line 1
I haven't been able to find if this is a known issue of a configuration element that I'm missing.

Ensure that you've selected the correct Slick driver for your database as described in the Lagom documentation on Relational Database Persistent Entities:
jdbc-defaults.slick.driver = "slick.driver.MySQLDriver$"

Related

Hortonworks Hive ODBC Driver DB-240000

DB-240000 ODBC error: [Hortonworks][Hardy] (80) Syntax or semantic
analysis error thrown in server while executing query.
Error message from server: Error while compiling statement: FAILED:
ParseException line 1:12 cannot recognize input near 'ALL_ROWS'
'*' '/' in hint name SQLState: 37000
Sample query
WDB-200001 SQL statement 'SELECT /*+ ALL_ROWS */ A.test FROM table A' could not be executed.
Syntax looks right as per documentation (https://docs.oracle.com/cd/E11882_01/server.112/e41084/sql_elements006.htm#SQLRF51108)
Or is there a missing param on the odbc configuration?
https://hortonworks.com/wp-content/uploads/2015/10/Hortonworks-Hive-ODBC-Driver-User-Guide.pdf
Use Native Query Key Name Default Value Required UseNativeQuery Clear
(0) No Architecting the Future of Big Data Hortonworks Inc. Page 71
Description When this option is enabled (1), the driver does not
transform the queries emitted by an application, so the native query
is used. When this option is disabled (0), the driver transforms the
queries emitted by an application and converts them into an equivalent
from in HiveQL. Note: If the application is Hive-aware and already
emits Hive
Could this be an issue with HDP versioning?
Is there a missing Param
in the ODBC connection string?

JdbcSQLException executing PostgreSQL query with 'MATCH simple' in H2

I'm trying to run in development mode (with H2) a setup currently used in production with a PostgreSQL database and I get an error. It would be best if I could reuse the production SQL without any change to it.
Using this setup:
# H2 Database
spring.datasource.datasource-class-name=org.h2.jdbcx.JdbcDataSource
spring.datasource.url=jdbc:h2:mem:userregistry;DB_CLOSE_DELAY=-1;MODE=PostgreSQL
This query:
CREATE TABLE IF NOT EXISTS users.user_userrole (
user_signum VARCHAR(20) NOT NULL,
role VARCHAR(255) NOT NULL,
CONSTRAINT user_userrole_pk PRIMARY KEY (user_signum, role),
CONSTRAINT user_fk FOREIGN KEY (user_signum) REFERENCES users.user (signum) MATCH SIMPLE,
CONSTRAINT role_fk FOREIGN KEY (role) REFERENCES users.userrole
(role_name) MATCH SIMPLE
);
Raises this exception:
org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement "<<SQL OMITTED FOR BREVITY>>";
expected "INDEX, ON, NOT, DEFERRABLE, NOCHECK, CHECK, ,, )"; [42001-185]
Note that I am already using Mode=PostgreSQL. Any ideas?
Thanks
The H2 database does not support MATCH SIMPLE (same as Oracle, MS SQL Server, Apache Derby).

Error running SQL queries with Liquibase

I'm using Liquibase to create tables in DB2. I have a simple example changelog that tries to drop and then create a table.
The SQL statements work fine via my DbVisualizer tool (which uses the same JDBC driver as Liquibase) and also works fine when submitted via the db2 command line tool.
Here's the Liquibase input file:
--changeset dank:1 runAlways=true failOnError:false
DROP TABLE AAA_SCHEMA.FOO
--changeset dank:2 runAlways=true
CREATE TABLE AAA_SCHEMA.FOO ( MYID INTEGER NOT NULL )
Here's the error message I get:
Caused by: com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error:
SQLCODE=-104, SQLSTATE=42601, SQLERRMC=DROP TABLE AAA_SCHEMA.FOO;
;, DRIVER=4.18.60
The IBM error code -104 is about syntax problems. Based on looking at the error message my guess is that it has something to do with the end of line character ";". But I've tried the query with and without the semi-colon. The semi-colon is accepted by IBM's own db2 too, so it seems like a valid choice.
Any help in figuring out the cause of this error is much appreciated.
The problem was me forgetting to start my native sql file with this required line:
--liquibase formatted sql
Doh!

H2 Oracle compatibility for RENAME COLUMN statement

I am using Oracle for production and H2 as an in-memory test database. I'm having trouble with Oracle compatibility for the "rename column" statement.
Specifically, the Oracle statement is:
alter table "SOME_TABLE" rename column "COLUMN_A" to "COLUMN_B" ;
I'm using Spring and Liquibase to set up the test environment and believe I have specified "use Oracle compatibility mode" correctly, but this statement is rejected by H2 as follows:
Caused by: org.h2.jdbc.JdbcSQLException: Syntax error in SQL statement
"ALTER TABLE ""SOME_TABLE"" RENAME COLUMN[*] ""COLUMN_A"" TO ""COLUMN_B"" "; expected "TO"; SQL statement:
alter table "SOME_TABLE" rename column "COLUMN_A" to "COLUMN_B" [42001-174]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:332)
at org.h2.message.DbException.getSyntaxError(DbException.java:197)
at org.h2.command.Parser.getSyntaxError(Parser.java:504)
at org.h2.command.Parser.read(Parser.java:2867)
at org.h2.command.Parser.parseAlterTable(Parser.java:4971)
at org.h2.command.Parser.parseAlter(Parser.java:4412)
at org.h2.command.Parser.parsePrepared(Parser.java:316)
at org.h2.command.Parser.parse(Parser.java:289)
at org.h2.command.Parser.parse(Parser.java:265)
at org.h2.command.Parser.prepareCommand(Parser.java:226)
at org.h2.engine.Session.prepareLocal(Session.java:437)
at org.h2.engine.Session.prepareCommand(Session.java:380)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1138)
at org.h2.jdbc.JdbcStatement.executeInternal(JdbcStatement.java:168)
at org.h2.jdbc.JdbcStatement.execute(JdbcStatement.java:156)
at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:294)
I am finding through research that this level of compatibility may not be implemented by H2 at this time. Are there any extensions I can write or any other actions I can take to rename a column in both Oracle and H2.
Thanks!
Steve Nester

I am unable to create table in MySql (Error 1064)

While I am creating a table In MySql, I am getting an error. I don't know What the problem is, but it will be helpful if I understand the reason behinId it.
Query:
create table publish(
From varcahar(60),
To varchar(60)
);
ERROR 1064 (42000): 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 'From varcahar(60),To varchar(60))' at line 1
Several errors:
1.- From and To are reserverd words you need to escape them
2.- varcahr -> varchar
Final code:
create table publish(
`From` varchar(60),
`To` varchar(60)
);
It says varcahr(60) not varchar(60)
Spelling problem
create table publish(From varchar(60),To varchar(60));
This is the right one. You misspelled varchar
And also From and To are reserved words. Check this Reserved Words In MySql

Resources