0

Description:

hello! I am creating a dynamic web project using eclipse and using embedded derby database. Below is the code that i am using to connect/create embedded derby database.

private boolean connect() throws Exception{
        Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
        String dbURL = "jdbc:derby:codejava/webdb;create=true";
        Connection conn = DriverManager.getConnection(dbURL);
        if (conn != null) {
            return true;
        }else{
            return false;
        }
    }

Problem:

When i run the code first time it creates the database but when i check the application folder in webapps folder in tomcat, i found no database folder. Tomcat folder is in my C:/ Directory and searching the C:/ directory i found the database folder in my eclipse folder because that's where i start my IDE from if i am not wrong.

Question:

How can i create the database folder inside my application folder in tomcat/webapps folder?

Nishat Lakhani
  • 733
  • 1
  • 8
  • 20
Usman Riaz
  • 2,920
  • 10
  • 43
  • 66

2 Answers2

1

If you use this format

 <property name="url" value="jdbc:derby:d:/DBDIR;create=true"/>

you can specify where you want your DB to be.

So I guess that in your case the DB has ended up somewhere relative to codejava/webdb

Scary Wombat
  • 44,617
  • 6
  • 35
  • 64
0

Since the eclipse IDE is running Tomcat and derby is run by tomcat it's not inside webapps.

This might help you

http://www.eclipse.org/articles/article.php?file=Article-EclipseDbWebapps/index.html

devd
  • 370
  • 10
  • 28