1 2 24 25 package com.lutris.appserver.server.sessionEnhydra.persistent; 26 27 import java.sql.PreparedStatement ; 28 import java.sql.ResultSet ; 29 import java.sql.SQLException ; 30 31 import com.lutris.appserver.server.sql.DBConnection; 32 import com.lutris.appserver.server.sql.Query; 33 import com.lutris.appserver.server.user.User; 34 35 41 class UserNumSessionsQuery implements Query { 42 43 private User user; 44 private static final Integer zero = new Integer (0); 45 46 50 UserNumSessionsQuery(User user) { 51 this.user = user; 52 } 53 54 60 public ResultSet executeQuery(DBConnection conn) 61 throws SQLException { 62 String sql = "select count (*) num from " 63 + PersistentSessionHome.dbTableName 64 + " where userName = ?"; 65 PreparedStatement stmt = conn.prepareStatement(sql); 66 stmt.setString(1, user.getName()); 67 return conn.executeQuery(stmt, sql); 68 } 69 70 79 public Object next(ResultSet rs) throws SQLException { 80 if (rs.next()) { 81 return new Integer (rs.getString("num")); 82 } 83 return zero; 84 } 85 86 } 87 | Popular Tags |