I'm trying to use Circumflex ORM (as suggested on StackOverflow - here, here and here) to connect to a local (embedded) Apache Derby database over JDBC from a Scala project (built with simple build tool). I've followed the instructions carefully, but am having some interesting problems.
Here's the driver and URL components of the cx.properties file:
orm.connection.driver=org.apache.derby.jdbc.EmbeddedDriver
orm.connection.url=jdbc:derby:derbyDB
(These map to the "instance creation of the reflected driver and create Connection" model with raw JDBC, or the equivalents in persistence.xml - Circumflex is using a short and sweet properties file because, you know, it's not XML and that's a good thing.)
The dependencies I've added in my sbt project file that are directly relevant are:
"ru.circumflex" % "circumflex-orm" % "1.0",
"org.apache.derby" % "derby" % "10.6.1.0"
I have created a short example model which defines a simplified version of the table that the documentation describes:
import java.sql.DriverManager
import ru.circumflex.orm._
class Country extends Record[Country] {
val code = "code" VARCHAR(2)
val name = "name" TEXT
}
object Country extends Table[Country]
This seems to compile okay, and I can instantiate the Country object (using a Scala 2.8.0 RC5 shell invoked with sbt console) and create an object ActiveRecord-style and then save it like this:
val c = new Country
c.code := "US"
c.name := "United States of America"
c.save
According to the documentation, this should run a validation over the object and then insert it into the database. I get the following exception:
java.sql.SQLSyntaxErrorException: Syntax error: Encountered "public" at line 1, column 13.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement.<init>(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement20.<init>(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedPreparedStatement30...
I found this thread where someone is having a similar problem with 'Encountered "public"' and Apache Derby, but the replies don't seem to suggest a useful way of going forward.
Any ideas what might be causing this?