Package org.jpox.exceptions

Examples of org.jpox.exceptions.JPOXDataStoreException


            }
        }
        catch (SQLException e)
        {
            String msg = LOCALISER.msg("055002", "Long", "" + param, column, e.getMessage());
            throw new JPOXDataStoreException(msg, e);
        }

        return value;
    }
View Full Code Here


                ((PreparedStatement) ps).setTime(param, (Time)value);
            }
        }
        catch (SQLException e)
        {
            throw new JPOXDataStoreException(LOCALISER.msg("055001","java.sql.Time","" + value, column, e.getMessage()), e);
        }
    }
View Full Code Here

        {
            value = ((ResultSet) rs).getTime(param);
        }
        catch (SQLException e)
        {
            throw new JPOXDataStoreException(LOCALISER.msg("055002","java.sql.Time","" + param, column, e.getMessage()), e);
        }

        return value;
    }
View Full Code Here

            {
                ((PreparedStatement)ps).setBytes(param,null);
            }
            catch (SQLException sqle)
            {
        throw new JPOXDataStoreException(LOCALISER.msg("055001","Object", "" + param, column, sqle.getMessage()),sqle);
            }
        }
        else
        {
            try
            {
                // Use Java serialisation, else byte-streaming, and if not determined then Java serialisation
                if (getJavaTypeMapping().isSerialised())
                {
                    // Serialised field so just perform basic Java serialisation for retrieval
                    if (!(value instanceof Serializable))
                    {
                        throw new JPOXDataStoreException(LOCALISER.msg("055005", value.getClass().getName()));
                    }
                    BlobImpl b = new BlobImpl(value);
                    ((PreparedStatement) ps).setBytes(param, b.getBytes(0, (int) b.length()));
                }
                else if (value instanceof boolean[])
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromBooleanArray(value);
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof char[])
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromCharArray(value);
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof double[])
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromDoubleArray(value);
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof float[])
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromFloatArray(value);
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof int[])
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromIntArray(value);
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof long[])
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromLongArray(value);
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof short[])
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromShortArray(value);
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof Boolean[])
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromBooleanObjectArray(value);
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof Byte[])
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromByteObjectArray(value);
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof Character[])
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromCharObjectArray(value);
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof Double[])
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromDoubleObjectArray(value);
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof Float[])
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromFloatObjectArray(value);
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof Integer[])
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromIntObjectArray(value);
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof Long[])
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromLongObjectArray(value);
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof Short[])
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromShortObjectArray(value);
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof BigDecimal[])
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromBigDecimalArray(value);
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof BigInteger[])
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromBigIntegerArray(value);
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof byte[])
                {
                    ((PreparedStatement) ps).setBytes(param, (byte[]) value);
                }
                else if (value instanceof java.util.BitSet)
                {
                    byte[] data = TypeConversionHelper.getByteArrayFromBooleanArray(TypeConversionHelper.getBooleanArrayFromBitSet((java.util.BitSet) value));
                    ((PreparedStatement) ps).setBytes(param, data);
                }
                else if (value instanceof java.awt.image.BufferedImage)
                {
                    ByteArrayOutputStream baos = new ByteArrayOutputStream(8192);
                    ImageIO.write((BufferedImage) value, "jpg", baos);
                    byte[] buffer = baos.toByteArray();
                    baos.close();
                    ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
                    ((PreparedStatement) ps).setBytes(param, buffer);
                    bais.close();
                }
                else
                {
                    // Fall back to just perform Java serialisation for storage
                    if (!(value instanceof Serializable))
                    {
                        throw new JPOXDataStoreException(LOCALISER.msg("055005", value.getClass().getName()));
                    }
                    BlobImpl b = new BlobImpl(value);
                    ((PreparedStatement) ps).setBytes(param, b.getBytes(0, (int) b.length()));
                }
            }
            catch (Exception e)
            {
                throw new JPOXDataStoreException(LOCALISER.msg("055001","Object","" + value, column, e.getMessage()),e);
            }
        }
    }
View Full Code Here

        {
            bytes = ((ResultSet) rs).getBytes(param);
        }
        catch (SQLException sqle)
        {
            throw new JPOXDataStoreException(LOCALISER.msg("055002","Object", "" + param, column, sqle.getMessage()),sqle);
        }
        if (bytes == null)
        {
            return null;
        }

        // Use Java serialisation, else byte-streaming, and if not determined then Java serialisation
        if (getJavaTypeMapping().isSerialised())
        {
            // Serialised field so just perform basic Java deserialisation for retrieval
            try
            {
                BlobImpl blob;
                blob = new BlobImpl(bytes);
                return blob.getObject();
            }
            catch (SQLException sqle)
            {
                // Impossible (JDK 1.6 use of free())
                return null;
            }
        }
        else if (getJavaTypeMapping().getType().equals(ClassNameConstants.BOOLEAN_ARRAY))
        {
            return TypeConversionHelper.getBooleanArrayFromByteArray(bytes);
        }
        else if (getJavaTypeMapping().getType().equals(ClassNameConstants.BYTE_ARRAY))
        {
            return bytes;
        }
        else if (getJavaTypeMapping().getType().equals(ClassNameConstants.CHAR_ARRAY))
        {
            return TypeConversionHelper.getCharArrayFromByteArray(bytes);
        }
        else if (getJavaTypeMapping().getType().equals(ClassNameConstants.DOUBLE_ARRAY))
        {
            return TypeConversionHelper.getDoubleArrayFromByteArray(bytes);
        }
        else if (getJavaTypeMapping().getType().equals(ClassNameConstants.FLOAT_ARRAY))
        {
            return TypeConversionHelper.getFloatArrayFromByteArray(bytes);
        }
        else if (getJavaTypeMapping().getType().equals(ClassNameConstants.INT_ARRAY))
        {
            return TypeConversionHelper.getIntArrayFromByteArray(bytes);
        }
        else if (getJavaTypeMapping().getType().equals(ClassNameConstants.LONG_ARRAY))
        {
            return TypeConversionHelper.getLongArrayFromByteArray(bytes);
        }
        else if (getJavaTypeMapping().getType().equals(ClassNameConstants.SHORT_ARRAY))
        {
            return TypeConversionHelper.getShortArrayFromByteArray(bytes);
        }
        else if (getJavaTypeMapping().getType().equals(ClassNameConstants.JAVA_LANG_BOOLEAN_ARRAY))
        {
            return TypeConversionHelper.getBooleanObjectArrayFromByteArray(bytes);
        }
        else if (getJavaTypeMapping().getType().equals(ClassNameConstants.JAVA_LANG_BYTE_ARRAY))
        {
            return TypeConversionHelper.getByteObjectArrayFromByteArray(bytes);
        }
        else if (getJavaTypeMapping().getType().equals(ClassNameConstants.JAVA_LANG_CHARACTER_ARRAY))
        {
            return TypeConversionHelper.getCharObjectArrayFromByteArray(bytes);
        }
        else if (getJavaTypeMapping().getType().equals(ClassNameConstants.JAVA_LANG_DOUBLE_ARRAY))
        {
            return TypeConversionHelper.getDoubleObjectArrayFromByteArray(bytes);
        }
        else if (getJavaTypeMapping().getType().equals(ClassNameConstants.JAVA_LANG_FLOAT_ARRAY))
        {
            return TypeConversionHelper.getFloatObjectArrayFromByteArray(bytes);
        }
        else if (getJavaTypeMapping().getType().equals(ClassNameConstants.JAVA_LANG_INTEGER_ARRAY))
        {
            return TypeConversionHelper.getIntObjectArrayFromByteArray(bytes);
        }
        else if (getJavaTypeMapping().getType().equals(ClassNameConstants.JAVA_LANG_LONG_ARRAY))
        {
            return TypeConversionHelper.getLongObjectArrayFromByteArray(bytes);
        }
        else if (getJavaTypeMapping().getType().equals(ClassNameConstants.JAVA_LANG_SHORT_ARRAY))
        {
            return TypeConversionHelper.getShortObjectArrayFromByteArray(bytes);
        }
        else if (getJavaTypeMapping().getType().equals(BigDecimal[].class.getName()))
        {
            return TypeConversionHelper.getBigDecimalArrayFromByteArray(bytes);
        }
        else if (getJavaTypeMapping().getType().equals(BigInteger[].class.getName()))
        {
            return TypeConversionHelper.getBigIntegerArrayFromByteArray(bytes);
        }
        else if (getJavaTypeMapping().getJavaType() != null &&
            getJavaTypeMapping().getJavaType().getName().equals(java.util.BitSet.class.getName()))
        {
            return TypeConversionHelper.getBitSetFromBooleanArray((boolean[])TypeConversionHelper.getBooleanArrayFromByteArray(bytes));
        }
        else if (getJavaTypeMapping().getJavaType() != null &&
                getJavaTypeMapping().getJavaType().getName().equals(java.awt.image.BufferedImage.class.getName()))
        {
            try
            {
                return ImageIO.read(new ByteArrayInputStream(bytes));
            }
            catch (IOException e)
            {
                throw new JPOXDataStoreException(LOCALISER.msg("055002","Object", "" + param, column, e.getMessage()),e);
            }
        }
        else
        {
            // Fallback to just perform basic Java deserialisation for retrieval
View Full Code Here

                    }

                }
                catch (IOException e)
                {
                    throw new JPOXDataStoreException("Error reading Oracle CLOB object: param = " + param, e);
                }

                value = sbuf.toString();

                if (value.length() == 0)
                {
                    value = null;
                }
                else if (value.equals(getDatabaseAdapter().getSurrogateForEmptyStrings()))
                {
                    value = "";
                }
            }
        }
        catch (SQLException e)
        {
            throw new JPOXDataStoreException(LOCALISER.msg("RDBMSMapping.UnableToGetParam","String", "" + param), e);
        }

        return value;
    }
View Full Code Here

                mconn.release();
            }
        }
        catch (SQLException e)
        {
            throw new JPOXDataStoreException("Update of CLOB value failed: " + textStmt, e);
        }
    }
View Full Code Here

        {
            ((PreparedStatement) ps).setInt(param, value ? 1 : 0);
        }
        catch (SQLException e)
        {
            throw new JPOXDataStoreException(LOCALISER.msg("055001", "boolean", "" + value, column, e.getMessage()), e);
        }
    }
View Full Code Here

            {
                value = true;
            }
            else
            {
                throw new JPOXDataStoreException(LOCALISER.msg("055006", "Types.SMALLINT", "" + intValue));
            }

            if( column == null || column.getColumnMetaData() == null || !column.getColumnMetaData().isAllowsNull() )
            {
                if (((ResultSet) rs).wasNull())
                {
                    throw new NullValueException(LOCALISER.msg("055003",column));
                }
            }
        }
        catch (SQLException e)
        {
            throw new JPOXDataStoreException(LOCALISER.msg("055002","Boolean", "" + param, column, e.getMessage()), e);
        }

        return value;
    }
View Full Code Here

        {
            ((PreparedStatement) ps).setShort(param, value);
        }
        catch (SQLException e)
        {
            throw new JPOXDataStoreException(LOCALISER.msg("055001", "short", "" + value, column, e.getMessage()), e);
        }
    }
View Full Code Here

TOP

Related Classes of org.jpox.exceptions.JPOXDataStoreException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.