Server problem saving items on DB

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
StevenP
Posts: 90
Joined: Mon Jun 09, 2008 1:31 pm

Server problem saving items on DB

Post by StevenP »

» Find Revision
L2J Revision 2996:
L2JDP Revision 6048:

Code: Select all

Could not insert item 268531593 into DB: Reason: Data truncation: Out of range value adjusted for column 'time' at row 1com.mysql.jdbc.MysqlDataTruncation: Data truncation: Out of range value adjusted for column 'time' at row 1        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3513)        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3447)        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951)        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)        at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2554)        at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:1761)        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:2046)        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1964)        at com.mysql.jdbc.PreparedStatement.executeUpdate(PreparedStatement.java:1949)        at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeUpdate(NewProxyPreparedStatement.java:105)        at net.sf.l2j.gameserver.model.L2ItemInstance.insertIntoDb(L2ItemInstance.java:1501)        at net.sf.l2j.gameserver.model.L2ItemInstance.updateDatabase(L2ItemInstance.java:1287)        at net.sf.l2j.gameserver.model.itemcontainer.ItemContainer.updateDatabase(ItemContainer.java:585)        at net.sf.l2j.gameserver.network.clientpackets.Logout.runImpl(Logout.java:64)        at net.sf.l2j.gameserver.network.clientpackets.L2GameClientPacket.run(L2GameClientPacket.java:76)        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)        at java.lang.Thread.run(Thread.java:619) 
net.sf.l2j.gameserver.model.L2ItemInstance.insertIntoDb(L2ItemInstance.java:1501):

Code: Select all

 con = L2DatabaseFactory.getInstance().getConnection();PreparedStatement statement = con.prepareStatement("INSERT INTO items (owner_id,item_id,count,loc,loc_data,enchant_level,object_id,custom_type1,custom_type2,mana_left,time) " +"VALUES (?,?,?,?,?,?,?,?,?,?,?)");statement.setInt(1, _ownerId);statement.setInt(2, _itemId);statement.setLong(3, getCount());statement.setString(4, _loc.name());statement.setInt(5, _locData);statement.setInt(6, getEnchantLevel());statement.setInt(7, getObjectId());statement.setInt(8, _type1);statement.setInt(9, _type2);statement.setInt(10, getMana());[color=#800040][b]statement.setLong(11, getTime());[/b][/color]statement.executeUpdate();_existsInDb = true;_storedInDb = true;statement.close(); 
Any ideas ?
User avatar
janiii
L2j Veteran
L2j Veteran
Posts: 4269
Joined: Wed May 28, 2008 3:15 pm
Location: Slovakia

Re: Server problem saving items on DB

Post by janiii »

from sql:

Code: Select all

`time` decimal NOT NULL default 0,
and your error means, that in db the column time can not hold the value you inserted. like if you would like to insert an elephant into a shoe carton ^^

the problem is, that the decimal was created using default values:
M is the total number of digits (the precision) and D is the number of digits after the decimal point (the scale). ... If D is omitted, the default is 0. If M is omitted, the default is 10.
and then in your code, it probably wanted to insert a number with more than 10 digits (the default value of decimal)..
but our time property is in milliseconds, so it has 13 digits! so it cannot be inserted, and is truncated to 10 digits precision. baaaaad..

fix:

Code: Select all

ALTER TABLE `items` CHANGE `time` `time` decimal(13) NOT NULL default 0;
DO NOT EVEN TRY TO MESS WITH ME!
forum flOOder dancing dEVILoper
I don't give private support - PM will be ignored!
StevenP
Posts: 90
Joined: Mon Jun 09, 2008 1:31 pm

Re: Server problem saving items on DB

Post by StevenP »

Thx janiii, I've already updated to decimal(20) as in accounts table, before reading your reply. I think that this will be committed..

`time` decimal NOT NULL default 0, come from update 5992

I'll adjust to (13) to save some DB space :wink:
User avatar
janiii
L2j Veteran
L2j Veteran
Posts: 4269
Joined: Wed May 28, 2008 3:15 pm
Location: Slovakia

Re: Server problem saving items on DB

Post by janiii »

Code: Select all

Index: sql/items.sql===================================================================--- sql/items.sql   (revision 6056)+++ sql/items.sql   (working copy)@@ -10,7 +10,7 @@   `custom_type1` INT DEFAULT 0,   `custom_type2` INT DEFAULT 0,   `mana_left` decimal(3,0) NOT NULL default -1,-  `time` decimal NOT NULL default 0,+  `time` decimal(13) NOT NULL default 0,   PRIMARY KEY (`object_id`),   KEY `key_owner_id` (`owner_id`),   KEY `key_loc` (`loc`),

Code: Select all

ALTER TABLE `items` CHANGE `time` `time` decimal(13) NOT NULL default 0;
DO NOT EVEN TRY TO MESS WITH ME!
forum flOOder dancing dEVILoper
I don't give private support - PM will be ignored!
User avatar
janiii
L2j Veteran
L2j Veteran
Posts: 4269
Joined: Wed May 28, 2008 3:15 pm
Location: Slovakia

Re: Server problem saving items on DB

Post by janiii »

thx StevenP for reporting, commited in dp [6059]
DO NOT EVEN TRY TO MESS WITH ME!
forum flOOder dancing dEVILoper
I don't give private support - PM will be ignored!
metallinacho
Posts: 24
Joined: Thu Mar 20, 2008 6:21 pm

Re: Server problem saving items on DB

Post by metallinacho »

i have the last rev...and when i log out i lose all the items...any idea on whats going on?

Could not insert item 268504459 into DB: Reason: Unknown column 'time' in 'field
list'
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Unknown column 'time'
in 'field list'

Could not restore inventory : com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorE
ception: Unknown column 'time' in 'field list'

would that be the time_of_use column ??
if so should i delete that...im pretty confused as u can see...
Post Reply