Bringing up an old topic...

Was there ever any resolution for using the baseDir parameter with
embedded databases?

String baseDir = "C:/mydocuments/h2db";
String[] args = new String[]{"-baseDir", baseDir};
server = new Server();
int exitCode = server.run(args, System.out);1

This code seems to drop the baseDir argument on the floor as none of
the data files ever make it into the C:/mydocuments/h2db directory.

thanks,

milly

Hi,
Sorry, I think that -baseDir simply does not work for the H2 Console
(when using embedded databases, that is database URL of the form
jdbc:h2:test) , it only works for the server mode (database URL
jdbc:h2:tcp://localhost/test). I will think about a way to make the
-baseDir parameter work with embedded databases as well. As a
workaround (not a good one I know) you could use the Console to
connect to a database in server mode (you would need to start the
server as well of course, using the -baseDir parameter).
Thomas

On 4/26/07, 簡建勝 <[EMAIL PROTECTED]> wrote:

- Hide quoted text -
- Show quoted text -
> import java.io.File;
> import javax.servlet.*;
> import java.sql.*;
> import org.h2.tools.Server;

> public class DBStart implements ServletContextListener {
>     private Server server;

>     public void contextInitialized(ServletContextEvent servletContextEvent)
> {
>         try {
>             File file = new File("DB");
>             if(!file.exists()){
>                 file.mkdir();
>             }
>             System.out.println("DB
> Starting..........................................................................................................");
>             String[] DBArgs = new
> String[]{"-webPort","8082","-webAllowOthers","true","-baseDir",
> file.getAbsolutePath()};
>             for(int i = 0;i<DBArgs.length;i++){
>                 System.out.println(DBArgs[i]);
>             }
>             server = Server.createWebServer(DBArgs);
>             server.start();
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }

>     public void contextDestroyed(ServletContextEvent servletContextEvent) {
>         try {
>             server.stop();
>             System.out.println("DB Shutdown
> ..........................................................................................................");
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>     }
> }

> Every time,When I start the tomcat service,the database(if db not exists)
> always create in tomcat 'root' folder just like 'C:\Program Files\Apache
> Software Foundation\Tomcat 5.5'  !!!!
> but my '-baseDir' is assign 'C:\Program Files\Apache Software
> Foundation\Tomcat 5.5\DB', How to use '-baseDir'??

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to