-1

I am using SQuirelL client to connect to MariaDB. My OS is Ubuntu. I have downloaded the Mariadb driver (mariadb-java-client-1.5.2.jar) to the proper location and linked it in the SQuirelL client. I have setup a database, and am able to create tables in it. But things go south when i try creating any object where i use a DELIMITER. I have even tried with the mysql driver, mysql-connector-java-5.1.38.jar. but same error.

this is my SQL -

DELIMITER //

CREATE FUNCTION FortyTwo() RETURNS TINYINT DETERMINISTIC
BEGIN
 DECLARE x TINYINT;
 SET x = 42;
 RETURN x;
END 

//

DELIMITER ;

and this is the error -

    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 'DELIMITER //

CREATE FUNCTION FortyTwo() RETURNS TINYINT DETERMINISTIC
BEGIN
 DE' at line 1
Query is : DELIMITER //

CREATE FUNCTION FortyTwo() RETURNS TINYINT DETERMINISTIC
BEGIN
 DECLARE x TINYINT
SQLState:  42000
ErrorCode: 1064
Error occurred in:
DELIMITER //

CREATE FUNCTION FortyTwo() RETURNS TINYINT DETERMINISTIC
BEGIN
 DECLARE x TINYINT

I will greatly appreciate any help ! Thanks

A. Jose
  • 1
  • 1

1 Answers1

2

DELIMITER is not a valid MariaDB SQL command.
Look at the documentation. You won't find it there.

DELIMITER is a MySQL Client command:

mysql> help

List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
...
delimiter (\d) Set statement delimiter.
...

You generally don't need delimiters, since you only execute one command at a time when using JDBC.

They can be batched if needed for performance, but they should still be submitted to the JDBC driver one at a time.

Community
  • 1
  • 1
Andreas
  • 154,647
  • 11
  • 152
  • 247