Your example doesn't work. The statement starts with four double quotes but it should be tree.
SQL( """"
Though I don't know about the socialUser
object, I tried a simpler example and it worked with H2.
Question
Trying to insert user data to DB. Checked all the parameters, data is correct, but it still throw the exception
java.sql.SQLException: Parameter index out of range (1 > number of parameters, which is 0).
The code is like this
DB.withConnection {
implicit c =>
SQL( """"
insert into tUser (fname, lname, fullname, avatarurl, email, extuid, service)
values ({fname}, {lname}, {fullname}, {avatarurl}, {email}, {extuid}, {service})
""").on(
'fname -> socialUser.firstName,
'lname -> socialUser.lastName,
'fullname -> socialUser.fullName,
'avatarurl -> socialUser.avatarUrl.getOrElse(Option.empty),
'email -> socialUser.email.getOrElse(Option.empty),
'extuid -> socialUser.id.id,
'service -> socialUser.id.providerId
).executeUpdate()
}
Tried to use H2, now I use MySQL, but have the same error
Solution
Your example doesn't work. The statement starts with four double quotes but it should be tree.
SQL( """"
Though I don't know about the socialUser
object, I tried a simpler example and it worked with H2.