View Javadoc

1   /*
2    * $Id: DerbyDataSourceFactoryBean.java 22123 2011-06-06 11:11:23Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
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  }