Apache Derby - Database created but not found

China☆狼群 提交于 2019-12-24 11:58:20

问题


This is in continuation to my previous question

I'm trying to embed a derby database in my web application. I'm able to embed it, though I am facing glitches. Here's the snapshot of my project structure.

I wonder why class.forName("org.apache.derby.jdbc.EmbededDriver") is throwing exception?

java.lang.ClassNotFoundException: org.apache.derby.jdbc.EmbededDriver

To overcome this, I have used

DriverManager.registerDriver(new org.apache.derby.jdbc.EmbeddedDriver());

Which works well. Why is it so? Also, Where would it create database if coded like this. I cannot spot the database.

connection = DriverManager.getConnection("jdbc:derby:MyDbTest;create=true");

I checked in tomcat webapps and eclipse workspace, I didn't find database.

If given this way, I can spot it.

connection = DriverManager.getConnection("jdbc:derby:E:/MyDbTest;create=true");

回答1:


class.forName("org.apache.derby.jdbc.EmbededDriver")

Threw an exception because there is a 'd' missing from embedded.

See here for information about specifying the location of databases on the file system.

connecting to a file-based derby database



来源:https://stackoverflow.com/questions/14184625/apache-derby-database-created-but-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!