KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quikj > application > web > talk > plugin > SessionDisconnectCDR


1 /*
2  * SessionCDR.java
3  *
4  * Created on June 29, 2002, 3:38 PM
5  */

6
7 package com.quikj.application.web.talk.plugin;
8
9 import java.sql.*;
10 /**
11  *
12  * @author amit
13  */

14 public class SessionDisconnectCDR implements CDRInterface
15 {
16     // database table name constant
17
private static final String JavaDoc SESSION_DISC_CDR_TABLE_NAME = "cdr_session_disc_tbl";
18     
19     // database table column name constants
20
private static final String JavaDoc SESSION = "session";
21     private static final String JavaDoc CODE = "code";
22     private static final String JavaDoc TIMESTAMP = "time_stamp";
23     
24     private String JavaDoc session;
25     private int code;
26     private java.util.Date JavaDoc timestamp;
27
28     
29     /** Creates a new instance of SessionCDR */
30     public SessionDisconnectCDR(String JavaDoc session, int code)
31     {
32         timestamp = new java.util.Date JavaDoc();
33         this.session = session;
34         this.code = code;
35     }
36     
37     public PreparedStatement generateSQLCDR()
38     throws SQLException
39     {
40         String JavaDoc sql = "insert into "
41         + SESSION_DISC_CDR_TABLE_NAME
42         + " values (?, ?, ?)";
43         
44         PreparedStatement ps = CDRHandler.getInstance().getConnection().prepareStatement(sql);
45         ps.setString(1, session);
46         ps.setInt(2, code);
47         ps.setTimestamp(3, new java.sql.Timestamp JavaDoc(timestamp.getTime()));
48         return ps;
49     }
50     
51     public String JavaDoc generateXMLCDR()
52     {
53         return "<CDR type=\"session-disconnect\" session=\"" + session
54         + "\" code=\"" + code
55         + "\" time-stamp=\"" + timestamp.getTime() + "\"/>\n";
56     }
57 }
58
Popular Tags