H2 Spring Maven Integration

pom.xml [code] <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>1.4.193</version> <scope>compile</scope> </dependency> [/code] database.properties [code] orm.connection.driver_class=org.h2.Driver orm.connection.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=TRUE orm.connection.username=sa orm.connection.password= orm.dialect=org.hibernate.dialect.H2Dialect orm.pool_size = 1 orm.show_sql=true orm.hbm2ddl.auto=create/update [/code] spring.xml [code] <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd"> <mvc:annotation-driven /> <mvc:default-servlet-handler /> <mvc:resources mapping="/resources/**" location="/resources/" /> <mvc:resources mapping="/css/**" location="/css/" /> <context:component-scan base-package="com.xxx" />

Resource Bundles

Resource Bundles allows you to create localized multi language supported applications for each locale. The abstract class “java.util.ResourceBundle” offers such locale-specific resources. The abstract class is sub classed by “PropertyResourceBundle” and “ListResourceBundle”. Each of these classes have their own implementations in a application which I’ll show some examples how to. However, there are some important

Javascript Useful Resources

Finding out whether the browser is Google Chrome [javascript] isChrome = /Chrome/.test(navigator.userAgent) &amp;&amp; /Google Inc/.test(navigator.vendor); [/javascript] Getting element by class name and changing styles [javascript] var arr = document.getElementsByClassName("ui-datepicker-trigger"); var arrLength = arr.length for (i = 0; i < arrLength; i++) { arr[i].textContent=" "; arr[i].style.height="15px"; arr[i].style.padding="4px"; } [/javascript] Getting element by id and appending style’s

FileVisitor Interface Sample

In this sample file visitor interface you can list all the folders and their regarding files   import java.io.IOException; import java.nio.file.FileVisitResult; import java.nio.file.FileVisitor; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; public class MyFileVisitor implements FileVisitor<Path> { private Map<String, List<String>> data = new HashMap<>(); private Map<String, IOException>

Useful Oracle DB Hints

Importing data imp userid=baldo_test/baldotest1@localbaldo file=c:\oracle\temp\localbaldo.dmp log=c:\oracle\temp\imp.log   Export data exp  userid=baldo_test/baldotest1@localbaldo file=user1.dmp Dropping a user [code]DROP USER USERNAME CASCADE;[/code] Creating a user [code] CREATE USER USERNAME IDENTIFIED BY "PASSWORD" ACCOUNT UNLOCK; [/code] Truncate Table PL/SQL http://stackoverflow.com/a/11030009 [code] BEGIN FOR c IN (SELECT table_name, constraint_name FROM user_constraints WHERE constraint_type = ‘R’) LOOP EXECUTE IMMEDIATE (‘alter table ‘

HSQL In-memory database hibernate maven config example

maven dependency <properties> <!– PROJECT DEPENDENCIES BEGIN –> <hsqldb.version>2.3.4</hsqldb.version> <!– PROJECT DEPENDENCIES END –> </properties> <dependencies> <dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId> <version>${hsqldb.version}</version> </dependency> </dependencies> hibernate configuration <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.archive.autodetection">class,hbm</property> <property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property> <property name="hibernate.show_sql">true</property> <property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property> <property name="hibernate.connection.username">sa</property> <property name="hibernate.connection.password">1</property> <property name="hibernate.connection.url">jdbc:hsqldb:mem:testdb</property> <property name="hibernate.hbm2ddl.auto">create</property> <mapping class="de.gameduell.entity.User"

Cohesion, Coupling and Composition

Cohesion Cohesion indicates that the depth of the relation in between to sources or dependencies. This is not related to a practical coding, but a mentality that helps to write a better maintainable code. High Cohesion means clear separation of concerns, low cohesion is the reverse. To provide high cohesion in an application, we shall separate

IS-A and HAS-A Relationships

IS-A Relationship in OOP this sort of relationship refers to inheritance, both class and interface types. In the hierarchy tree, traversing up to determine whether the relation corresponds to IS-A. Assume the situation simply; Class A implements Interface B, then we can say Class A IS-A Interface B, this is to traverse up, and the reverse