1

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.

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");
srk
  • 4,857
  • 12
  • 65
  • 109

1 Answers1

3
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

Community
  • 1
  • 1
BillRobertson42
  • 12,602
  • 4
  • 40
  • 57
  • I see that the database is created in the eclipse installation directory. – srk Jan 07 '13 at 16:58
  • When deployed through tomcat, it's creating database inside bin directory of tomcat – srk Jan 07 '13 at 17:12
  • Default would be current working directory, most operating systems that is where the program (eclipse.exe or java for tomcat) is launched from. – BillRobertson42 Jan 07 '13 at 17:34