1
2
3
4
5
6
7
8
9
10
11 package org.mule.transport.jdbc.config;
12
13 public class DerbyDataSourceFactoryBean extends AbstractDataSourceFactoryBean
14 {
15 private static final String DRIVER_CLASS_NAME = "org.apache.derby.jdbc.EmbeddedDriver";
16 private static final String JDBC_URL_PREFIX = "jdbc:derby:";
17 private static final String MEMORY_SUB_SUBPROTOCOL = "memory";
18
19 protected boolean create = false;
20 protected String database;
21 protected String subsubprotocol = MEMORY_SUB_SUBPROTOCOL;
22
23 public DerbyDataSourceFactoryBean()
24 {
25 super();
26 driverClassName = DRIVER_CLASS_NAME;
27 updateUrl();
28 }
29
30 protected void updateUrl()
31 {
32 StringBuilder buf = new StringBuilder(64);
33 buf.append(JDBC_URL_PREFIX);
34 buf.append(subsubprotocol);
35 buf.append(":");
36 buf.append(database);
37
38 if (create)
39 {
40 buf.append(";create=true");
41 }
42
43 url = buf.toString();
44 }
45
46 public String getDatabase()
47 {
48 return database;
49 }
50
51 public void setDatabase(String database)
52 {
53 this.database = database;
54 updateUrl();
55 }
56
57 public boolean isCreate()
58 {
59 return create;
60 }
61
62 public void setCreate(boolean create)
63 {
64 this.create = create;
65 updateUrl();
66 }
67 }