Package com.pugh.sockso.db

Examples of com.pugh.sockso.db.Database


        st.setInt( 1, 123 );
        expect( st.executeQuery() ).andReturn( rs ).times( 1 );
        st.close();
        replay( st );
       
        final Database db = createMock( Database.class );
        expect( db.prepare((String)anyObject()) ).andReturn( st ).times( 1 );
        replay( db );
       
        final MyCoverSearch s = new MyCoverSearch( db );
        final String name = s.getMusicItemName( "ar123" );
       
View Full Code Here


        st.setInt( 1, 345 );
        expect( st.executeQuery() ).andReturn( rs ).times( 1 );
        st.close();
        replay( st );
       
        final Database db = createMock( Database.class );
        expect( db.prepare((String)anyObject()) ).andReturn( st ).times( 1 );
        replay( db );
       
        final MyCoverSearch s = new MyCoverSearch( db );
        final String name = s.getMusicItemName( "tr345" );
       
View Full Code Here

       
    }

    public void testGetMusicItemNameBadArgument() throws SQLException {

        final Database db = createMock( Database.class );
        replay( db );
       
        final MyCoverSearch s = new MyCoverSearch( db );
        boolean gotException = false;
       
View Full Code Here

        st.setInt( 1, albumId );
        expect( st.executeQuery() ).andReturn( rs ).times( 1 );
        st.close();
        replay( st );
       
        final Database db = createMock( Database.class );
        expect( db.prepare((String)anyObject()) ).andReturn( st ).times( 1 );
        replay( db );
       
        final MyCoverSearch s = new MyCoverSearch( db );
        final String name = s.getArtistName( albumId );
       
View Full Code Here

        st.setInt( 1, albumId );
        expect( st.executeQuery() ).andReturn( rs ).times( 1 );
        st.close();
        replay( st );
       
        final Database db = createMock( Database.class );
        expect( db.prepare((String)anyObject()) ).andReturn( st ).times( 1 );
        replay( db );
       
        final MyCoverSearch s = new MyCoverSearch( db );
        final String name = s.getArtistName( albumId );
       
View Full Code Here

        final PreparedStatement st = createMock(PreparedStatement.class);
        expect(st.executeQuery()).andReturn(rs);
        st.close();
        replay(st);

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

        coverer.setDatabase(db);
        final File[] dirs = coverer.getLocalCoverDirectories("ar123");
View Full Code Here

       
        PreparedStatement st = null;
               
        try {

            final Database db = getDatabase();
            final User user = getUser();
            final String sql = " insert into play_log ( track_id, date_played, user_id ) " +
                               " values ( ?, current_timestamp, ? ) ";
           
            st = db.prepare( sql );
            st.setInt( 1, track.getId() );
           
            if ( user != null )
                st.setInt( 2, user.getId() );
            else
View Full Code Here

        if ( user == null )
            if ( !p.get(Constants.WWW_UPLOADS_ALLOW_ANONYMOUS).equals(Properties.YES) )
                throw new BadRequestException( locale.getString("www.error.noAnonymousUploads"), 403 );

        // check there is a valid collection set for uploads
        final Database db = getDatabase();
        final String uploadsPath = Utils.getUploadsPath( db, p );
        if ( uploadsPath.equals("") )
            throw new BadRequestException( locale.getString("www.error.noUploadsDirectory"), 500 );
        final File uploadsDir = new File( uploadsPath );
        if ( !uploadsDir.canWrite() )
View Full Code Here

       
        PreparedStatement st = null;
       
        try {
       
            final Database db = getDatabase();
            final String sql = " update play_log " +
                               " set scrobbled = 1 " +
                               " where user_id = ? ";

            st = db.prepare( sql );
            st.setInt( 1, user.getId() );
            st.executeUpdate();

        }
       
View Full Code Here

        PreparedStatement st = null;
        ResultSet rs = null;
       
        try {
           
            final Database db = getDatabase();
            // use the date the track was played instead of the date it
            // was added to the collection.
            final String sql = Utils.replaceAll( "t.date_added", "l.date_played", Track.getSelectSql() ) +
                              " from play_log l " +
                                  " inner join tracks t " +
                                  " on t.id = l.track_id " +
                                  " inner join artists ar " +
                                  " on ar.id = t.artist_id " +
                                  " inner join albums al " +
                                  " on al.id = t.album_id " +
                                  " inner join genres g " +
                                  " on g.id = t.genre_id " +
                              " where l.user_id = ? " +
                                  " and l.scrobbled = 0 ";

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

            return Track.createListFromResultSet( rs );
View Full Code Here

TOP

Related Classes of com.pugh.sockso.db.Database

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.