Byte Type Is Returned After a Table Column of the Character Type Is Read in Java
Symptom
A column in a newly created database table is of the character type. However, after the column is read in Java, the returned type is byte.
For example, to create a sample table table01, run the following command:
1 2 3 4 |
CREATE TABLE IF NOT EXISTS table01( msg_id character(36), msg character varying(50) ); |
In Java, the code for reading the field of the character type is as follows:
1
|
ColumnMetaInfo(msg_id,1,Byte,true,false,1,true); |
Possible Causes
- CHARACTER(n) is a fixed-length character string. When the actual string length is insufficient, the database pads it with spaces. Then, Java uses the byte type to receive the string.
- CHARACTER VARYING(n) is a variable-length character string. Java uses the string type to receive it.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot