我从数据库中获取数据。我正在接受classcastexception。 在数据库中,我的ID保存为BIGINT,但在代码(对象)中很长。 铸造bigint时是否有问题?cast bigint long
5
A
回答
4
如果这是MySql,则应该使用java.math.BigDecimal
。
+0
感谢您的建议。我会尝试。你能告诉我BIGINT是否会导致任何问题? – 2011-04-05 14:56:13
+0
更新了我的答案。 – aioobe 2011-04-05 15:03:29
+0
是的,你是对的。 :) – 2011-04-05 15:03:37
7
您是否尝试将您的值转换为BigInteger,然后使用longValue()获取long值?它应该工作。 aioobe是正确的,也检查空值。
干杯!
相关问题
- 1. cast Long to BigDecimal
- 2. Java持久性标准; Cast Expression <Timestamp> to Expression <Long>?
- 3. NHibernate的LINQ BIGINT铸造
- 4. BigInt转换(gmp Bigint to botan bigint)
- 5. 关于long long long long
- 6. postgresql:将bytea转换为bigint
- 7. Mysql bigint到int
- 8. 用bigint和varchar'mysql'cast'问题
- 9. static cast或c style cast
- 10. DB2 BIGINT id生成
- 11. 置查询VARCHAR BIGINT转换
- 12. 在long(bigint)中存储时间戳的列中按日期进行分组
- 13. C long long golang
- 14. unsigned long long int
- 15. JPA Cast Exception
- 16. SQL服务器VARBINARY BIGINT是不同的
- 17. cast iqueryable
- 18. 将BIGINT UNSIGNED转换为INT
- 19. command.Parameters.GetValue无效的转换异常<long>
- 20. unsigned long long to binary
- 21. Arduino long long int doc
- 22. long double vs long int
- 23. newlib-nano long long support
- 24. 为什么不是common_type <long,unsigned long> :: type = long long?
- 25. IsNull()on bigint的最小值?
- 26. 这个scala错误是什么意思:“type mismatch; found :(((Long,Long),Long),)required:(((Long,Long),Long))⇒String”
- 27. Bigint到Datetime
- 28. 浮动为bigint
- 29. LINQ在BIGINT
- 30. Mysql Bigint VS Varchar
你用什么Java API来查询数据库?请提供一些代码。 – krookedking 2011-04-05 14:56:55
我正在使用Derby数据库。 'List list = openIncidentDao.getAll(); \t \t \t对(INT I = 0; I <则为list.size();我++){ \t \t \t \t openIncident =(OpenIncident)list.get(ⅰ); \t \t \t}' – 2011-04-05 15:00:54