我從數據庫中獲取數據。我正在接受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