1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.statistics.impl;
18
19 import java.sql.Connection;
20 import java.sql.PreparedStatement;
21 import java.sql.SQLException;
22
23 import javax.sql.DataSource;
24
25 /***
26 * <p>
27 * BatchedUserStatistics
28 * </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 */
34 public class BatchedUserStatistics extends BatchedStatistics
35 {
36
37
38
39
40
41
42 public boolean canDoRecordType(LogRecord rec)
43 {
44 return (rec instanceof UserLogRecord);
45 }
46
47 public BatchedUserStatistics(DataSource ds, int batchSize,
48 long msElapsedTimeThreshold, String name)
49 {
50 super(ds, batchSize, msElapsedTimeThreshold, name);
51 }
52
53 /***
54 * @param stm
55 * @param recordIterator
56 * @throws SQLException
57 */
58 protected void loadOneRecordToStatement(PreparedStatement stm, LogRecord rec)
59 throws SQLException
60 {
61 UserLogRecord record = (UserLogRecord) rec;
62
63 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 }
69
70 /***
71 * @param con
72 * @return
73 * @throws SQLException
74 */
75 protected PreparedStatement getPreparedStatement(Connection con)
76 throws SQLException
77 {
78 PreparedStatement stm;
79 stm = con
80 .prepareStatement("INSERT INTO USER_STATISTICS VALUES(?,?,?,?,?)");
81 return stm;
82 }
83
84 }