I am using “select count (*) total count from student where SnO =?AND Password = ?” I encountered this problem when querying the number of satisfied conditions. At that time, my code was as follows:
object count = map. Get (“total count”); return (int)count;
I suspect that the type of the returned number is long, so I report an error because the integer is an unchangeable type, and long and integer have no inheritance relationship and cannot be converted
①.
long count = (long) map. Get (“totalcount”); return (int)count;
use long first, and then turn it strongly
②.
Number num = (Number)map.get(“TotalCount”);
return num.intValue();
because java.lang.number is the parent of integer and long
Similar Posts:
- [Solved] mapper.xml Error: java.lang.AbstractMethodError: Method oracle/jdbc/driver/OracleResultSetImpl.getNString(Ljava/lang/String;)Ljava/lang/String; is abstract,
- [Solved] Mybatis Mapping Error: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ‘id’ in ‘class java.lang.String
- Get the time value from the database and report an error: Java sql. Timestamp cannot be cast to java. lang.Long
- [solved] exception: Java. Lang. arithmeticexception / by zero
- [Solved] MYSQL Error: “ Every derived table must have its own alias”
- How to Use awk to Analyze Nginx Log
- [Solved] Mybatis error: attempted to return null from a method with a primitive return type (int)
- Java.math.BigInteger cannot be cast to java.lang.Long [How to Solve]
- [Solved] org.apache.ibatis.binding.BindingException: Parameter ‘area_id’ not found. Available parameters are [areaId, param1]
- java.lang.nullpointerexception: cannot unbox null value [How to Solve]