Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
h2 embedded db support; updated formatting conventions not to auto-fo…
…rmat javadoc; added hsqldb and h2 to jdbc maven pom as optional deps
- Loading branch information
Keith Donald
committed
May 9, 2009
1 parent
93cf346
commit 96629c7
Showing
18 changed files
with
270 additions
and
144 deletions.
There are no files selected for viewing
114 changes: 57 additions & 57 deletions
114
eclipse-code-formatter.prefs → eclipse-code-formatter.xml
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...java/org/springframework/jdbc/datasource/embedded/AbstractEmbeddedDatabaseConfigurer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright 2002-2009 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.jdbc.datasource.embedded; | ||
|
||
import java.sql.Connection; | ||
import java.sql.SQLException; | ||
import java.sql.Statement; | ||
|
||
import javax.sql.DataSource; | ||
|
||
import org.apache.commons.logging.Log; | ||
import org.apache.commons.logging.LogFactory; | ||
|
||
/** | ||
* Base class for {@link EmbeddedDatabaseConfigurer} implementations providing common shutdown behaviour. | ||
* @author Oliver Gierke | ||
*/ | ||
abstract class AbstractEmbeddedDatabaseConfigurer implements EmbeddedDatabaseConfigurer { | ||
|
||
private static final Log logger = LogFactory.getLog(AbstractEmbeddedDatabaseConfigurer.class); | ||
|
||
public void shutdown(DataSource dataSource, String databaseName) { | ||
Connection connection = JdbcUtils.getConnection(dataSource); | ||
Statement stmt = null; | ||
try { | ||
stmt = connection.createStatement(); | ||
stmt.execute("SHUTDOWN"); | ||
} catch (SQLException e) { | ||
if (logger.isWarnEnabled()) { | ||
logger.warn("Could not shutdown embedded database", e); | ||
} | ||
} finally { | ||
JdbcUtils.closeStatement(stmt); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
.../main/java/org/springframework/jdbc/datasource/embedded/H2EmbeddedDatabaseConfigurer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2002-2009 the original author or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.jdbc.datasource.embedded; | ||
|
||
import org.springframework.util.ClassUtils; | ||
|
||
/** | ||
* Initializes a HSQL embedded database instance. | ||
* Call {@link #getInstance()} to get the singleton instance of this class. * | ||
* @author Oliver Gierke | ||
*/ | ||
final class H2EmbeddedDatabaseConfigurer extends AbstractEmbeddedDatabaseConfigurer { | ||
|
||
private static H2EmbeddedDatabaseConfigurer INSTANCE; | ||
|
||
private H2EmbeddedDatabaseConfigurer() { | ||
} | ||
|
||
/** | ||
* Get the singleton {@link HsqlEmbeddedDatabaseConfigurer} instance. | ||
* @return the configurer | ||
* @throws ClassNotFoundException if HSQL is not on the classpath | ||
*/ | ||
public static synchronized H2EmbeddedDatabaseConfigurer getInstance() throws ClassNotFoundException { | ||
if (INSTANCE == null) { | ||
ClassUtils.forName("org.h2.Driver", H2EmbeddedDatabaseConfigurer.class.getClassLoader()); | ||
INSTANCE = new H2EmbeddedDatabaseConfigurer(); | ||
} | ||
return INSTANCE; | ||
} | ||
|
||
public void configureConnectionProperties(ConnectionProperties properties, String databaseName) { | ||
properties.setDriverClass(org.h2.Driver.class); | ||
properties.setUrl(String.format("jdbc:h2:mem:%s;DB_CLOSE_DELAY=-1", databaseName)); | ||
properties.setUsername("sa"); | ||
properties.setPassword(""); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.