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?
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
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.