1/*2 * Licensed to the Apache Software Foundation (ASF) under one or more3 * contributor license agreements. See the NOTICE file distributed with4 * this work for additional information regarding copyright ownership.5 * The ASF licenses this file to You under the Apache License, Version 2.06 * (the "License"); you may not use this file except in compliance with7 * the License. You may obtain a copy of the License at8 * 9 * http://www.apache.org/licenses/LICENSE-2.010 * 11 * Unless required by applicable law or agreed to in writing, software12 * distributed under the License is distributed on an "AS IS" BASIS,13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14 * See the License for the specific language governing permissions and15 * limitations under the License.16 */17packageorg.apache.jetspeed.statistics.impl;
1819import java.sql.Connection;
20import java.sql.PreparedStatement;
21import java.sql.SQLException;
2223import javax.sql.DataSource;
2425/***26 * <p>27 * BatchedUserStatistics28 * </p>29 * 30 * @author <a href="mailto:chris@bluesunrise.com">Chris Schaefer </a>31 * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>32 * @version $Id: TestPortletEntityDAO.java,v 1.3 2005/05/24 14:43:19 ate Exp $33 */34publicclassBatchedUserStatisticsextendsBatchedStatistics35 {
3637/*38 * (non-Javadoc)39 * 40 * @see org.apache.jetspeed.statistics.impl.BatchedStatistics#canDoRecordType(org.apache.jetspeed.statistics.impl.LogRecord)41 */42publicboolean canDoRecordType(LogRecord rec)
43 {
44return (rec instanceof UserLogRecord);
45 }
4647publicBatchedUserStatistics(DataSource ds, int batchSize,
48long msElapsedTimeThreshold, String name)
49 {
50super(ds, batchSize, msElapsedTimeThreshold, name);
51 }
5253/***54 * @param stm55 * @param recordIterator56 * @throws SQLException57 */58protectedvoid loadOneRecordToStatement(PreparedStatement stm, LogRecord rec)
59 throws SQLException
60 {
61UserLogRecord record = (UserLogRecord) rec;
6263 stm.setString(1, record.getIpAddress());
64 stm.setString(2, record.getUserName());
65 stm.setTimestamp(3, record.getTimeStamp());
66 stm.setInt(4, record.getStatus());
67 stm.setLong(5, record.getMsElapsedTime());
68 }
6970/***71 * @param con72 * @return73 * @throws SQLException74 */75protected PreparedStatement getPreparedStatement(Connection con)
76 throws SQLException
77 {
78 PreparedStatement stm;
79 stm = con
80 .prepareStatement("INSERT INTO USER_STATISTICS VALUES(?,?,?,?,?)");
81return stm;
82 }
8384 }