データベース接続URLには必要に応じて属性を記述することができます。 Derbyはこれらの属性を、内部的にプロパティオブジェクトとして取り扱います。従って、DriverManager.getConnectionにPropertiesオブジェクトを渡すことで属性を指定することもできます。(これらの属性はシステムプロパティとして指定できません。DriverManager.getConnectionに渡すオブジェクトでのみ指定できます。)
これらの属性はDerby固有で、データベース接続URLに属性を指定する。にその一覧があります。
import java.util.Properties;
Connection conn = DriverManager.getConnection(
"jdbc:derby:sampleDB;create=true");
/* 属性をPropertiesオブジェクトに渡す。*/
Properties myProps = new Properties();
myProps.put("create", "true");
Connection conn = DriverManager.getConnection(
"jdbc:derby:sampleDB", myProps);
/* ユーザ名およびパスワードを渡す。*/
Connection conn = DriverManager.getConnection(
"jdbc:derby:sampleDB", "dba", "password");