** BEGIN NESTED EXCEPTION ** com.mysql.jdbc.CommunicationsException MESSAGE: Communications link failure due to underlying exception: ** BEGIN NESTED EXCEPTION ** java.io.EOFException STACKTRACE: java.io.EOFException at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:1956)This is quite a common problem which shows up when C3P0 is configured incorrectly or by using the default settings. The problem occurs when C3P0 is trying to use a connection already established by the pool but was closed by the database server. When C3P0 tries to use this already-closed connection, the error is thrown.
c3p0.preferredTestQuery=SELECT 1 c3p0.testConnectionOnCheckout=trueThis will force C3P0 to test each connection before passing it to the application.
hibernate.c3p0.acquire_increment hibernate.c3p0.idle_test_period hibernate.c3p0.timeout hibernate.c3p0.max_size hibernate.c3p0.max_statements hibernate.c3p0.min_size hibernate.c3p0.validateThe other properties should go to the c3p0.properties file located in the webapp class root folder.
java.sql.SQLException: com.mchange.v2.resourcepool.ResourcePoolException: Attempted to use a closed or broken resource poolEnsure that the timeout value configured for c3p0 does not not exceed the database server's wait timeout.
// Unmarshall XML to JavaBean CDF3Util cdf3Util = new CDF3Util (); CDFTransmissionFile file = cdf3Util.unmarshall (inputXml); // Marshall JavaBean to XML String outputXml = cdf3Util.marshall (file);Download: [mastercard-cdf3-lib.zip @ ~4.5MB]
public void initialized(Object arg0) public void attributesProcessed(Object arg0) public void fieldAdded(String arg0, Object parent, Object child) public void unmarshalled(Object object)
public void fieldAdded(String arg0, Object parent, Object child)
{
if (arg0.equals("XMLHotelItem"))
{
GwsHotelAvailabilityResponse hotelAvailability = (GwsHotelAvailabilityResponse) parent;
hotelAvailability.incrementErrorIndex();
GwsHotelInsideShopRate insideShopRate = new GwsHotelInsideShopRate ();
insideShopRate.setErrorIndex(hotelAvailability.getCurrentErrorIndex());
hotelAvailability.insertHotelInsideShopRate (insideShopRate);
}
// Hotel Description Handling
if (arg0.equals("hotelRates"))
{
GwsHotelCompleteAvailabilityResponse parentResponse = (GwsHotelCompleteAvailabilityResponse) parent;
parentResponse.incrementIndex();
} else
if (arg0.equals("descriptions"))
{
GwsHotelCompleteAvailabilityResponse parentResponse = (GwsHotelCompleteAvailabilityResponse) parent;
parentResponse.insertDescriptionString((String) child);
}
}
public void unmarshalled(Object object)
{
if (object instanceof GwsHotelCompleteAvailabilityResponse)
{
GwsHotelCompleteAvailabilityResponse response = (GwsHotelCompleteAvailabilityResponse) object;
// Set room master responses
if (response.getHotelTypeIndicator().equals("R"))
{
Iterator it = response.getHotelRates().iterator();
while (it.hasNext())
{
GwsHotelRate rate = (GwsHotelRate) it.next();
RoomMasterCodeTranslator trans = new RoomMasterCodeTranslator (rate.getBicCode());
rate.insertRoomTypeDescription(trans.getRoomQuality() + " room.");
rate.insertRoomTypeDescription(trans.getNumberOfBedsAsString() + " bed(s).");
rate.insertRoomTypeDescription(trans.getBedType() + " bed(s).");
}
}
}
}
}
Mapping unmapping = new Mapping (); unmapping.loadMapping(getClass().getResource(PATH_TO_CASTOR_MAPPING_FILE)); Unmarshaller un = new Unmarshaller (XmlResponse.class); un.setUnmarshalListener(new CustomXmlUnmarshalListener()); un.setIgnoreExtraElements(true); un.setMapping(unmapping); StringReader sr = new StringReader (xml); return (XmlResponse) un.unmarshal(sr);