getRank is returning a String
|
Hi,
I've tried to follow the tut of King Fox - the tut about setting up your highscores. I did everything i should do but it still wont work. It worked before (my co made them work) but i haven't heard from hin in a while, so i'm kinda stuck now. Note: I'm using eclipse (duh)
It gives me an error;Code:PreparedStatement stmt2 = db.prepare(generateQuery()); stmt2.setString(1, name); stmt2.setInt(2, player.getRank().ordinal()); stmt2.setLong(3, player.getSkills().getTotalXp());I tried everything possible, yet nothing. Probably some dumb method i'm overseeing.Code:the method ordinal() is undefined for the type String.
The console gives me this error:
Thanks in advanceCode:java.sql.SQLException: Incorrect integer value: '' for column 'rights' at row 1 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2002) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2624) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2127) at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1362) at com.rs.database.impl.Highscores.run(Highscores.java:41) at java.lang.Thread.run(Unknown Source)
Nassim
getRank is returning a String
As i said, i tried everything. Here's the next error:
Code:java.sql.SQLException: Incorrect integer value: 'Player' for column 'rights' at row 1 at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609) at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2002) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163) at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2624) at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2127) at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1362) at com.rs.database.impl.Highscores.run(Highscores.java:41) at java.lang.Thread.run(Unknown Source)
Code:CREATE TABLE IF NOT EXISTS `hs_users` ( `id` int(11) NOT NULL AUTO_INCREMENT, `username` varchar(40) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, `rights` int(1) NOT NULL DEFAULT '0', `overall_xp` bigint(20) NOT NULL, `attack_xp` int(11) NOT NULL, `defence_xp` int(11) NOT NULL, `strength_xp` int(11) NOT NULL, `constitution_xp` int(11) NOT NULL, `ranged_xp` int(11) NOT NULL, `prayer_xp` int(11) NOT NULL, `magic_xp` int(11) NOT NULL, `cooking_xp` int(11) NOT NULL, `woodcutting_xp` int(11) NOT NULL, `fletching_xp` int(11) NOT NULL, `fishing_xp` int(11) NOT NULL, `firemaking_xp` int(11) NOT NULL, `crafting_xp` int(11) NOT NULL, `smithing_xp` int(11) NOT NULL, `mining_xp` int(11) NOT NULL, `herblore_xp` int(11) NOT NULL, `agility_xp` int(11) NOT NULL, `thieving_xp` int(11) NOT NULL, `slayer_xp` int(11) NOT NULL, `farming_xp` int(11) NOT NULL, `runecrafting_xp` int(11) NOT NULL, `hunter_xp` int(11) NOT NULL, `construction_xp` int(11) NOT NULL, `summoning_xp` int(11) NOT NULL, `dungeoneering_xp` int(11) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=0;
Yea, as i said i tried everything I would think of. That includes using eclipse suggestions. I'll get there, somehow.
Try this
Go to player.java and add this
and then changeCode:public int getDBRank(){ if (getRights() == 0 && !isDicer()) return 0; if (getRights() == 0 && isDicer()) return 0; if (getRights() == 1) return 1; if (getRights() == 2 && !isOwner()) return 2; if (getRights() == 4) return 4; if (getRights() == 5) return 5; if (getRights() == 6) return 6; if (getRights() == 10) return 10; if (getRights() == 3) return 3; return 0; }
intoCode:stmt2.setInt(2, player.getRank().ordinal());
Code:stmt2.setInt(2, player.getRank());
Fixed - thanks to Chris.
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |