Enter code here...
import scalikejdbc._
java.sql.DriverManager.registerDriver(new Driver())
ConnectionPool.singleton("jdbc:mysql://localhost/table", "user", "password")
DB.autoCommit { implicit s =>
sql"""
DROP TABLE IF EXISTS table1
CREATE TABLE table1(
id serial NOT NULL PRIMARY KEY,
name VARCHAR(64)
)
""".execute.apply()
}
Enter code here...
DB.autoCommit { implicit s =>
sql"""
DROP TABLE IF EXISTS apikey;
CREATE TABLE apikey(
id serial NOT NULL PRIMARY KEY,
name VARCHAR(64)
)
""".execute.apply()
}
Error -
[main] ERROR s.StatementExecutor$$anon$1 - SQL execution failed (Reason:
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
TABLE apikey(
id serial NOT NULL PRIMARY KEY,
name ' at line 2):
DROP TABLE IF EXISTS apikey; CREATE TABLE apikey( id serial NOT NULL PRIMARY KEY, name VARCHAR(64) )
Enter code here...
DB.autoCommit { implicit s =>
sql"""
DROP TABLE apikey;
CREATE TABLE apikey(
id serial NOT NULL PRIMARY KEY,
name VARCHAR(64)
)
""".execute.apply()
}