mysql - How to insert Array[Byte] into binary datatype colunm with slick and mariadb? -


i attempted insert array[byte] binary datatype colunm scala , play framework , slick on mariadb. however, got error , data wasn't inserted.

execution exception [mysqldatatruncation: data truncation: incorrect string value: '\x85\x09\x9b\x08%b...' column 'userid' @ row 1] 

the data uuid use java.util.uuid. conversion uuid array[byte] implemented uuidhelper.scala this code.

how can insert array[byte] data database?

my environment this.

database:

mariadb 10.1.16  mariadb [test]> show full columns user; +-----------+--------------+-----------------+------+-----+---------+-------+---------------------------------+---------+ | field     | type         | collation       | null | key | default | | privileges                      | comment | +-----------+--------------+-----------------+------+-----+---------+-------+---------------------------------+---------+ | userid    | binary(16)   | null            | no   | pri | null    |       | select,insert,update,references |         | | firstname | varchar(254) | utf8_general_ci | yes  |     | null    |       | select,insert,update,references |         | | lastname  | varchar(254) | utf8_general_ci | yes  |     | null    |       | select,insert,update,references |         | | fullname  | varchar(254) | utf8_general_ci | yes  |     | null    |       | select,insert,update,references |         | | email     | varchar(254) | utf8_general_ci | yes  |     | null    |       | select,insert,update,references |         | | avatarurl | varchar(254) | utf8_general_ci | yes  |     | null    |       | select,insert,update,references |         | +-----------+--------------+-----------------+------+-----+---------+-------+---------------------------------+---------+ 

userid colunm uuid.

play-slick configuration:

slick.dbs.default.driver="slick.driver.mysqldriver$" slick.dbs.default.db.driver="com.mysql.jdbc.driver" 

play , scala version:

scalaversion := "2.11.7" librarydependencies ++= seq(   "com.mohiva" %% "play-silhouette" % "3.0.2",   "org.webjars" %% "webjars-play" % "2.4.0-1",   "net.codingwell" %% "scala-guice" % "4.0.0",   "net.ceedubs" %% "ficus" % "1.1.2",   "com.adrianhurt" %% "play-bootstrap3" % "0.4.4-p24",   "com.mohiva" %% "play-silhouette-testkit" % "3.0.2" % "test",   specs2 % test,   "com.typesafe.play" %% "play-slick" % "1.0.1",   "com.typesafe.play" %% "play-slick-evolutions" % "1.0.1",   //"com.h2database" % "h2" % "1.4.188",   "mysql" % "mysql-connector-java" % "5.1.39",   cache,   evolutions,   filters ) 

is byte array being used uuid? if so, suggest generate hex of uuid,

insert ... (uuid, ...)     values     (unhex(?), ...) 

(i don't know correct syntax substitution in slick.)

as side note, uuids terrible scaling.

more

that is, not try store calling "characters" binary(16). "bytes" ("blob", not "clob") stuff should stored in binary.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -