Package com.pugh.sockso.db

Examples of com.pugh.sockso.db.Database.prepare()


        PreparedStatement st = null;
       
        try {

            // check user owns playlist before deleting it
            st = db.prepare( sql );
            st.setInt( 1, id );
            st.setInt( 2, user.getId() );
            rs = st.executeQuery();
            if ( !rs.next() )
                throw new BadRequestException( "You don't own that playlist", 403 );
View Full Code Here


            final Request req = getRequest();
            final String path = convertPath( req.getArgument("path") );
            final String sql = Track.getSelectFromSql() +
                    " where t.path = ? ";
           
            st = db.prepare( sql );
            st.setString( 1, path );
            rs = st.executeQuery();
           
            if ( !rs.next() )
                throw new BadRequestException( locale.getString("www.error.trackNotFound"), 404 );
View Full Code Here

            final Database db = getDatabase();
            final String sql = " select c.path " +
                               " from collection c " +
                               " where c.id = ? ";
            st = db.prepare( sql );
            st.setInt( 1, collectionId );
            rs = st.executeQuery();

            // check the collection exists and we got it's root path
            if ( rs.next() ) {
View Full Code Here

                        " on ar.id = t.artist_id " +
                    " group by ar.id, ar.name " +
                    " order by playCount desc " +
                    " limit ? ";
           
            st = db.prepare( sql );
            st.setInt( 1, total );
            rs = st.executeQuery();
           
            final List<Artist> topArtists = new ArrayList<Artist>();
           
View Full Code Here

                        " on al.id = t.album_id " +
                        " group by artistId, artistName, albumId, albumName, albumYear, " +
                        "trackId, trackName, trackPath, trackNo, genreId, genreName, dateAdded " +
                    " limit ? ";

            st = db.prepare( sql );
            st.setInt( 1, total );
            rs = st.executeQuery();
           
            return Track.createListFromResultSet( rs );
View Full Code Here

                      " on ar.id = al.artist_id " +
                  " group by albumId, albumName, albumYear, artistId, artistName " +
                  " order by mostRecent desc " +
                  " limit ? ";

            st = db.prepare( sql );
            st.setInt( 1, total );
            rs = st.executeQuery();

            final List<Album> recentAlbums = new ArrayList<Album>();
            while ( rs.next() ) {
View Full Code Here

            final PreparedStatement st = createNiceMock( PreparedStatement.class );
            expect( st.execute() ).andReturn( true );
            replay( st );
           
            Database db = createMock( Database.class );
            expect( db.prepare((String)anyObject()) ).andReturn( st ).anyTimes();
           
            replay( db );
           
            final Properties p = new DBProperties( db );
            p.save();
View Full Code Here

        expect( st.executeQuery() ).andReturn( rs );
        st.close();
        replay( st );

        final Database db = createMock( Database.class );
        expect( db.prepare((String)anyObject()) ).andReturn( st ).times( 1 );
        replay( db );

        final Session sess = new Session( db, req, null );
        User user = sess.getCurrentUser();
View Full Code Here

        final PreparedStatement st = createNiceMock( PreparedStatement.class );
        expect( st.executeQuery() ).andReturn( rs );
        replay( st );
       
        final Database db = createMock( Database.class );
        expect( db.prepare((String)anyObject()) ).andReturn( st ).times( 2 );
        replay( db );
       
        final DBCollectionManager colMan = new DBCollectionManager( db, p, indexer );
       
        try {
View Full Code Here

        st.setInt( 1, 10 );
        expect( st.executeQuery() ).andReturn( rs ).times( 1 );
        replay( st );
       
        final Database db = createMock( Database.class );
        expect( db.prepare((String)anyObject()) ).andReturn( st ).times( 1 );
        replay( db );
       
        final Latester b = new Latester();
        b.setProperties( p );
        b.setDatabase( db );
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.