// Retrieve the L2Player from the characters table of the database
con = L2DatabaseFactory.getInstance().getConnection();
statement = con.createStatement();
statement2 = con.createStatement();
pl_rset = statement.executeQuery("SELECT * FROM `characters` WHERE `obj_Id`=" + objectId + " LIMIT 1");
ps_rset = statement2.executeQuery("SELECT `class_id` FROM `character_subclasses` WHERE `char_obj_id`=" + objectId + " AND `isBase`=1 LIMIT 1");
if(pl_rset.next() && ps_rset.next())
{
final int classId = ps_rset.getInt("class_id");
final boolean female = pl_rset.getInt("sex") == 1;
final L2PlayerTemplate template = CharTemplateTable.getInstance().getTemplate(classId, female);