List of usage examples for java.sql SQLNonTransientException SQLNonTransientException
public SQLNonTransientException(String reason, Throwable cause)
SQLTransientException
object with a given reason
and cause
. From source file:org.apache.cassandra.cql.jdbc.HandleObjects.java
private static Long fromString(String source) throws SQLException { long millis = 0; if (source.isEmpty() || source.toLowerCase().equals("now")) return System.currentTimeMillis(); // Milliseconds since epoch? else if (source.matches("^\\d+$")) { try {/*w ww . j a v a 2s.c om*/ Long.parseLong(source); } catch (NumberFormatException e) { throw new SQLNonTransientException( String.format("unable to make long (for date) from: '%s'", source), e); } } // Last chance, attempt to parse as date-time string else { try { millis = DateUtils.parseDate(source, iso8601Patterns).getTime(); } catch (ParseException e1) { throw new SQLNonTransientException( String.format("unable to coerce '%s' to a formatted date (long)", source), e1); } } return millis; }
From source file:org.apache.cassandra.cql.jdbc.HandleObjects.java
private static final ByteBuffer javaObject(Object object) throws SQLException { byte[] bytes = null; try {// ww w .j av a 2 s . c o m // Serialize to a byte array ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(bos); out.writeObject(object); out.close(); // Get the bytes of the serialized object bytes = bos.toByteArray(); } catch (IOException e) { throw new SQLNonTransientException("Problem serializing the Java object", e); } return ByteBuffer.wrap(bytes); }