Package org.sql2o

Examples of org.sql2o.Sql2oException


    public Object getObject(String columnName){
        Integer index = columnNameToIdxMap.get(
                isCaseSensitive?columnName
                :columnName.toLowerCase());
        if(index!=null) return getObject(index);
        throw new Sql2oException(String.format("Column with name '%s' does not exist", columnName));
    }
View Full Code Here


    @SuppressWarnings("unchecked")
    public <V> V getObject(int columnIndex, Class clazz){
        try{
            return (V) throwIfNull(clazz, quirks.converterOf(clazz)).convert(getObject(columnIndex));
        } catch (ConverterException ex){
            throw new Sql2oException("Error converting value", ex);
        }
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public <V> V getObject(String columnName, Class clazz) {
        try{
            return (V) throwIfNull(clazz, quirks.converterOf(clazz)).convert(getObject(columnName));
        } catch (ConverterException ex){
            throw new Sql2oException("Error converting value", ex);
        }
    }
View Full Code Here

                String colMapName = isCaseSensitive ? colName : colName.toLowerCase();
                columnNameToIdxMap.put(colMapName, colIdx - 1);
            }
        }
        catch (SQLException e) {
            throw new Sql2oException("Error while reading metadata from database", e);
        }

        lt.setColumns(columns);
    }
View Full Code Here

        } else {
            String errorMsg = "Property with name '" + propertyName + "' not found on class " + this.clazz.toString();
            if (this.caseSensitive) {
                errorMsg += " (You have turned on case sensitive property search. Is this intentional?)";
            }
            throw new Sql2oException(errorMsg);
        }
    }
View Full Code Here

        } else {
            String errorMsg = "Property with name '" + propertyName + "' not found on class " + this.clazz.toString();
            if (this.caseSensitive) {
                errorMsg += " (You have turned on case sensitive property search. Is this intentional?)";
            }
            throw new Sql2oException(errorMsg);
        }
    }
View Full Code Here

        return new ObjectConstructor() {
            public Object newInstance() {
                try {
                    return theUnsafe.allocateInstance(clazz);
                } catch (InstantiationException e) {
                    throw new Sql2oException("Could not create a new instance of class " + clazz, e);
                }
            }
        };
    }
View Full Code Here

            return new ObjectConstructor() {
                public Object newInstance() {
                    try {
                        return ctor.newInstance((Object[])null);
                    } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
                        throw new Sql2oException("Could not create a new instance of class " + clazz, e);
                    }
                }
            };
        } catch (Throwable e) {
            throw new Sql2oException("Could not find parameter-less constructor of class " + clazz, e);
        }
    }
View Full Code Here

            return; // dont try to set null to a setter to a primitive type.
        }
        try {
            this.method.invoke(obj, value);
        } catch (IllegalAccessException e) {
            throw new Sql2oException("error while calling setter method with name " + method.getName() + " on class " + obj.getClass().toString(), e);
        } catch (InvocationTargetException e) {
            throw new Sql2oException("error while calling setter method with name " + method.getName() + " on class " + obj.getClass().toString(), e);
        }
    }
View Full Code Here

    public Object getProperty(Object obj) {
        try {
            return this.field.get(obj);
        } catch (IllegalAccessException e) {
            throw new Sql2oException("could not get field " + this.field.getName() + " on class " + obj.getClass().toString(), e);
        }
    }
View Full Code Here

TOP

Related Classes of org.sql2o.Sql2oException

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.