Package org.apache.tapestry.contrib.jdbc

Examples of org.apache.tapestry.contrib.jdbc.IStatement


    }

    public Publisher[] getPublishers()
    {
        Connection connection = null;
        IStatement statement = null;
        ResultSet set = null;

        List list = new ArrayList();

        try
        {
            connection = getConnection();

            StatementAssembly assembly = new StatementAssembly();

            assembly.newLine("SELECT PUBLISHER_ID, NAME");
            assembly.newLine("FROM PUBLISHER");
            assembly.newLine("ORDER BY NAME");

            statement = assembly.createStatement(connection);

            set = statement.executeQuery();

            while(set.next())
            {
                Integer primaryKey = (Integer) set.getObject(1);
                String name = set.getString(2);
View Full Code Here


     */

    public Person[] getPersons()
    {
        Connection connection = null;
        IStatement statement = null;
        ResultSet set = null;

        List list = new ArrayList();

        try
        {
            connection = getConnection();

            StatementAssembly assembly = buildBasePersonQuery();
            assembly.newLine("ORDER BY LAST_NAME, FIRST_NAME");

            statement = assembly.createStatement(connection);

            set = statement.executeQuery();

            Object[] columns = new Object[Person.NUM_COLUMNS];

            while(set.next())
            {
View Full Code Here

    public Person getPerson(Integer personId)
        throws FinderException
    {
        Connection connection = null;
        IStatement statement = null;
        ResultSet set = null;

        Person result = null;

        try
        {
            connection = getConnection();

            StatementAssembly assembly = buildBasePersonQuery();
            assembly.newLine("WHERE ");
            assembly.add("PERSON_ID = ");
            assembly.addParameter(personId);
            assembly.newLine("ORDER BY LAST_NAME, FIRST_NAME");

            statement = assembly.createStatement(connection);

            set = statement.executeQuery();

            if (!set.next())
                throw new FinderException("Person #" + personId
                        + " does not exist.");
View Full Code Here

    public Book getBook(Integer bookId)
        throws FinderException
    {
        Connection connection = null;
        IStatement statement = null;
        ResultSet set = null;

        Book result = null;

        try
        {
            connection = getConnection();

            StatementAssembly assembly = buildBaseBookQuery();
            assembly.addSep(" AND ");
            assembly.add("book.BOOK_ID = ");
            assembly.addParameter(bookId);

            statement = assembly.createStatement(connection);

            set = statement.executeQuery();

            if (!set.next())
                throw new FinderException("Book " + bookId + " does not exist.");

            Object[] columns = new Object[Book.NUM_COLUMNS];
View Full Code Here

    private void executeUpdate(StatementAssembly assembly)
        throws XRemoveException
    {
        Connection connection = null;
        IStatement statement = null;

        try
        {
            connection = getConnection();

            statement = assembly.createStatement(connection);

            statement.executeUpdate();

            statement.close();
            statement = null;

            connection.close();
            connection = null;
        }
View Full Code Here

    private void validateUniquePerson(String firstName, String lastName,
            String email)
        throws RegistrationException
    {
        Connection connection = null;
        IStatement statement = null;
        ResultSet set = null;

        String trimmedEmail = email.trim().toLowerCase();
        String trimmedLastName = lastName.trim().toLowerCase();
        String trimmedFirstName = firstName.trim().toLowerCase();

        try
        {
            connection = getConnection();

            StatementAssembly assembly = new StatementAssembly();
            assembly.newLine("SELECT PERSON_ID");
            assembly.newLine("FROM PERSON");
            assembly.newLine("WHERE ");

            assembly.add("LOWER(EMAIL) = ");
            assembly.addParameter(trimmedEmail);

            statement = assembly.createStatement(connection);
            set = statement.executeQuery();

            if (set.next())
                throw new RegistrationException(
                        "Email address is already in use by another user.");

            close(null, statement, set);

            assembly = new StatementAssembly();
            assembly.newLine("SELECT PERSON_ID");
            assembly.newLine("FROM PERSON");
            assembly.newLine("WHERE ");

            assembly.add("LOWER(FIRST_NAME) = ");
            assembly.addParameter(trimmedFirstName);
            assembly.addSep(" AND ");
            assembly.add("LOWER(LAST_NAME) = ");
            assembly.addParameter(trimmedLastName);

            statement = assembly.createStatement(connection);
            set = statement.executeQuery();

            if (set.next())
                throw new RegistrationException(
                        "Name provided is already in use by another user.");
View Full Code Here

     * The master query is for querying by some mixture of title, author and publisher.
     */

    public int masterQuery(MasterQueryParameters parameters, SortOrdering sortOrdering)
    {
        IStatement statement = null;
        Connection connection = null;

        // Forget any current results.

        _results = null;
View Full Code Here

     * Queries on books owned by a given person, sorted by title.
     */

    public int ownerQuery(Integer ownerId, SortOrdering sortOrdering)
    {
        IStatement statement = null;
        Connection connection = null;

        // Forget any current results.

        _results = null;
View Full Code Here

     * Queries on books held (borrowed) by a given person, sorted by title.
     */

    public int holderQuery(Integer holderId, SortOrdering sortOrdering)
    {
        IStatement statement = null;
        Connection connection = null;

        // Forget any current results.

        _results = null;
View Full Code Here

        return getResultCount();
    }

    public int borrowerQuery(Integer borrowerId, SortOrdering sortOrdering)
    {
        IStatement statement = null;
        Connection connection = null;

        // Forget any current results.

        _results = null;
View Full Code Here

TOP

Related Classes of org.apache.tapestry.contrib.jdbc.IStatement

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.