Skip to content

Instantly share code, notes, and snippets.

View nhniches's full-sized avatar

NH Niches nhniches

  • NH Niches
  • Seacoast, NH
View GitHub Profile
@nhniches
nhniches / gist:5392324
Created April 16, 2013 00:07
show the DB and DB driver in spring
jdbcTemplate.execute(new ConnectionCallback() {
public Object doInConnection(Connection connection) throws SQLException, DataAccessException {
DatabaseMetaData dbmd = connection.getMetaData();
System.out.println("Database version: " + dbmd.getDatabaseProductVersion());
System.out.println("Driver version: " + dbmd.getDriverVersion());
return null;
}
});
@nhniches
nhniches / gist:5164333
Created March 14, 2013 19:20
start of (not finished) tests for creating a valid equals and hashcode method
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public abstract class GenericEqualityTester {
// tests we need for all object equality
// o1 == o2, o1 != p1
// object type is the same or if different fails
// compare fields (equals) works as follows:
@nhniches
nhniches / assembly.xml
Created January 13, 2013 14:17
sample maven assembly configuration file. Put in src/main/assemble. Customize as needed. Note, this is for a zip file that contains an executable jar with lots of depedent jars. For some reason tabs are being pasted in as "21" so remove them.
<assembly
2121xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>deploy</id>
<baseDirectory>${artifactId}</baseDirectory>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>tar.gz</format>
<format>zip</format>
@nhniches
nhniches / springcontextloadtester.java
Last active December 10, 2015 20:39
simple spring context loader test class
public class SpringLoadTester {
// this just is a quick main method to test to see if the spring stuff loads
// correctly...
public static void main(String[] args) {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(
"classpath:spring-applicationContext.xml");
DataSource ds = (DataSource) ctx.getBean("dataSource");
@nhniches
nhniches / parent.pom
Created December 5, 2012 18:20
sample POM file for parent poms
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.domain</groupId>
<artifactId>id</artifactId>
<packaging>pom</packaging>
<url>https://domain.com/site/</url>
<inceptionYear>2011</inceptionYear>
<version>3.1</version>
@nhniches
nhniches / log4j.xml
Created December 5, 2012 18:10
log4j configuration example
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/doc-files/log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="true">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out" />
<param name="Threshold" value="INFO" />
<layout class="org.apache.log4j.EnhancedPatternLayout">
<param name="ConversionPattern"