sql to create login account and add a character
Forum rules
READ NOW: L2j Forums Rules of Conduct
READ NOW: L2j Forums Rules of Conduct
-
- Posts: 2
- Joined: Fri Nov 12, 2010 2:42 am
sql to create login account and add a character
I want to run sql command and create a login account and then with sql commands again to add a character. But i cant find how the login is associated with the character. Any ideas?
- St3eT
- Posts: 961
- Joined: Sun Mar 07, 2010 6:50 pm
Re: sql to create login account and add a character
Character is associated with account in table characters.sql column account_name
Account:
Character:
Account:
Code: Select all
private static final String AUTOCREATE_ACCOUNTS_INSERT = "INSERT INTO accounts (login, password, lastactive, accessLevel, lastIP) values (?, ?, ?, ?, ?)";
Code: Select all
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement ps = con.prepareStatement(AUTOCREATE_ACCOUNTS_INSERT)) { ps.setString(1, user); ps.setString(2, Base64.encodeBytes(hash)); ps.setLong(3, System.currentTimeMillis()); ps.setInt(4, 0); ps.setString(5, address.getHostAddress()); ps.execute(); }
Character:
Code: Select all
private static final String INSERT_CHARACTER = "INSERT INTO characters (account_name,charId,char_name,level,maxHp,curHp,maxCp,curCp,maxMp,curMp,face,hairStyle,hairColor,sex,exp,sp,karma,fame,pvpkills,pkkills,clanid,race,classid,deletetime,cancraft,title,title_color,accesslevel,online,isin7sdungeon,clan_privs,wantspeace,base_class,newbie,nobless,power_grade,createDate) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
Code: Select all
try (Connection con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement statement = con.prepareStatement(INSERT_CHARACTER)) { statement.setString(1, _accountName); statement.setInt(2, getObjectId()); statement.setString(3, getName()); statement.setInt(4, getLevel()); statement.setInt(5, getMaxHp()); statement.setDouble(6, getCurrentHp()); statement.setInt(7, getMaxCp()); statement.setDouble(8, getCurrentCp()); statement.setInt(9, getMaxMp()); statement.setDouble(10, getCurrentMp()); statement.setInt(11, getAppearance().getFace()); statement.setInt(12, getAppearance().getHairStyle()); statement.setInt(13, getAppearance().getHairColor()); statement.setInt(14, getAppearance().getSex() ? 1 : 0); statement.setLong(15, getExp()); statement.setInt(16, getSp()); statement.setInt(17, getKarma()); statement.setInt(18, getFame()); statement.setInt(19, getPvpKills()); statement.setInt(20, getPkKills()); statement.setInt(21, getClanId()); statement.setInt(22, getRace().ordinal()); statement.setInt(23, getClassId().getId()); statement.setLong(24, getDeleteTimer()); statement.setInt(25, hasDwarvenCraft() ? 1 : 0); statement.setString(26, getTitle()); statement.setInt(27, getAppearance().getTitleColor()); statement.setInt(28, getAccessLevel().getLevel()); statement.setInt(29, isOnlineInt()); statement.setInt(30, isIn7sDungeon() ? 1 : 0); statement.setInt(31, getClanPrivileges()); statement.setInt(32, getWantsPeace()); statement.setInt(33, getBaseClass()); statement.setInt(34, getNewbie()); statement.setInt(35, isNoble() ? 1 : 0); statement.setLong(36, 0); statement.setDate(37, new Date(getCreateDate().getTimeInMillis())); statement.executeUpdate(); }
-
- Posts: 2
- Joined: Fri Nov 12, 2010 2:42 am
Re: sql to create login account and add a character
Ty man i didn`t noticed that... you helped a lot