For example, to set the user name and password:
Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
Properties p = new Properties();
p.setProperty("user", "sa");
p.setProperty("password", "manager");
p.setProperty("create", "true");
Connection conn = DriverManager.getConnection(
"jdbc:derby:mynewDB", p);
If you are running on JDK 6 or higher, you do not normally need to invoke
Class.forName(). In that environment, the
EmbeddedDriver loads automatically. The only exception to this
rule is when you need to shut down
in the middle of your
application and then restart it. To restart
, create a new instance
of the driver as follows:
Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();