Question

I'm trying to establish a database connection in my lift app using the mysql jdbc driver. I included the jar file in the eclipse build path, but building with importing the jar using import com.mysql._the app with sbt always throws the error:

object mysql is not a member of package com

Setting the classpath in the sdb.bat didn't help neither setting the system classpath variable.

set SCRIPT_DIR=%~dp0
java -Dscala.userjavacp=true -cp "%SCRIPT_DIR%\src\main\java\mysql.jar" -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx1024M -Xss2M -jar "%SCRIPT_DIR%\sbt-launch-0.12.1.jar" %*
Was it helpful?

Solution

SBT doesn't know anything about Eclipse build path. You need to add dependencies in the way SBT understands, e.g.:

add jars to lib and they will be placed on the project classpath. Not much else to it!

OTHER TIPS

I would suggest using the SBT Eclipse plugin and then use SBT to manage your dependencies which should keep the two programs in sync.

So, for MySQL, you'd want to modify your sbt configuration in your project to include:

libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.6"

Then all you would need to do is launch sbt, and type eclipse to update your Eclipse configuration files with the correct classpath. When you restart Eclipse, everything should work.

The plugin will also pick up files in the lib directory as noted in the other answer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top