Skip to content

Instantly share code, notes, and snippets.

View carlo-rtr's full-sized avatar

Carlo Barbara carlo-rtr

View GitHub Profile
@carlo-rtr
carlo-rtr / gist:7371834
Created November 8, 2013 14:33
Sending Email
package com.rtr.services.example;
import java.util.Date;
import java.util.Properties;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
@carlo-rtr
carlo-rtr / gist:6076182
Created July 25, 2013 01:34
java.sql.SQLException: Already closed.
org.hibernate.exception.GenericJDBCException: Could not close connection
at org.hibernate.exception.internal.StandardSQLExceptionConverter.convert(StandardSQLExceptionConverter.java:54) ~[commerce-service-0.1.0-SNAPSHOT.jar:na]
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:125) ~[commerce-service-0.1.0-SNAPSHOT.jar:na]
at org.hibernate.engine.jdbc.spi.SqlExceptionHelper.convert(SqlExceptionHelper.java:110) ~[commerce-service-0.1.0-SNAPSHOT.jar:na]
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.releaseConnection(LogicalConnectionImpl.java:327) ~[commerce-service-0.1.0-SNAPSHOT.jar:na]
at org.hibernate.engine.jdbc.internal.LogicalConnectionImpl.close(LogicalConnectionImpl.java:199) ~[commerce-service-0.1.0-SNAPSHOT.jar:na]
at org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl.close(JdbcCoordinatorImpl.java:141) ~[commerce-service-0.1.0-SNAPSHOT.jar:na]
at org.hibernate.engine.transaction.internal.Trans
@carlo-rtr
carlo-rtr / gist:6074470
Last active December 20, 2015 04:59
Dropwizard GenericObjectPool configuration
/*
Returns the maximum amount of time (in milliseconds) the borrowObject() method should block before throwing an exception when the pool is exhausted and the "when exhausted" action is WHEN_EXHAUSTED_BLOCK.
Defaulted to 1 second by DW
*/
pool.setMaxWait(configuration.getMaxWaitForConnection().toMilliseconds());
/*
Returns the minimum number of objects allowed in the pool before the evictor thread (if active) spawns new objects.
@carlo-rtr
carlo-rtr / DropwizardDAOTest
Created November 15, 2012 21:35
DAO Testing with Dropwizard hibernate
package com.rtr.infra.wizard.test;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.context.internal.ManagedSessionContext;
import org.junit.After;
import org.junit.Before;
public abstract class DropwizardDAOTest {