This is my application.conf:
db.default.driver=org.postgresql.Driver
db.default.url="postgres://postgres:postgres@localhost:5432/postgres"
db.default.user="postgres"
db.default.password= "postgres"
I downloaded postgresql-9.1-902.jdbc4.jar. Included it in my jar files by adding it as an external jar. Still it shows me this error that the driver was not found. Help?
I'd say the PostgreSQL driver isn't really on your classpath after all, but since you haven't shown the exact text of the error message it's hard to be sure. It would help if you could (a) show the exact copied and pasted text of the full error message and traceback; and (b) show exactly where you put the PgJDBC jar.
Consider adding some debug code that prints out the contents of System.getProperty("java.class.path")
during your app's startup. Also add a block that does something like:
try {
Class.forName("org.postgresql.Driver")
} catch (ClassNotFoundException ex) {
// Log or abort here
}
This should tell you something about the class's visibility. Because of the complexity of class loading on modern JVMs and frameworks it won't be conclusive - there are just too many class loaders.
I am using postgresql 9.1-901.jdbc4 in my project and I configured it like this:
Build.scala:
import sbt._
import Keys._
import PlayProject._
object ApplicationBuild extends Build {
val appName = "project_name"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
// Add your project dependencies here,
"postgresql" % "postgresql" % "9.1-901.jdbc4"
)
val main = PlayProject(appName, appVersion, appDependencies, mainLang = JAVA).settings(
// Add your own project settings here
)
}
application.conf
db.default.driver=org.postgresql.Driver
db.default.url="jdbc:postgresql://localhost:5432/project_name"
db.default.user=postgres
db.default.password=mypw
db.default.partitionCount=1
db.default.maxConnectionsPerPartition=5
db.default.minConnectionsPerPartition=5
Then I used following combo when taking it to use:
play clean
play compile
play eclipsify
play ~run
Alternatively you could type play dependencies
after this to see if its properly loaded.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With