将整数转换为字符串NOT NUMERIC

时间:2021-10-10 23:01:14

So what I'm trying to do is convert an INTEGER type into a string from a jdbc to put in a jtextfield, unfortunately the String.OfValue cannot convert my Integer type but can for my NUMBERIC type.

所以我要做的是将INTEGER类型转换为jdbc中的字符串以放入jtextfield,遗憾的是String.OfValue不能转换我的Integer类型,但可以转换为我的NUMBERIC类型。

**Did not use numeric because auto incrementation won't work on a numeric for some odd reason (if you know the solution to this please tell me)

**没有使用数字,因为出于某种奇怪的原因,自动增量无法对数字起作用(如果您知道解决方法,请告诉我)

HERES my string method

HERES我的字符串方法

      String sql ="select * from patient where patient_id='"+Table_click+"'";
      pst =conn.prepareStatement(sql);
      rs=pst.executeQuery();
      if (rs.next()) {
         String add1 =pst.toString();
         p_id.setText(add1);
      }

Here is my error message

这是我的错误消息

java.sql.SQLSyntaxErrorException: Comparisons between 'INTEGER' and 'CHAR (UCS_BASIC)' are not supported. Types must be comparable. String types must also have matching collation. If collation does not match, a possible solution is to cast operands to force them to the default collation (e.g. SELECT tablename FROM sys.systables WHERE CAST(tablename AS VARCHAR(128)) = 'T1')

java.sql.SQLSyntaxErrorException:不支持“INTEGER”和“CHAR(UCS_BASIC)”之间的比较。类型必须具有可比性。字符串类型还必须具有匹配的排序规则。如果排序规则不匹配,可能的解决方案是转换操作数以强制它们进行默认排序规则(例如SELECT tablename FROM sys.systables WHERE CAST(tablename AS VARCHAR(128))='T1')

1 个解决方案

#1


0  

If I understand your problem correctly,

如果我理解你的问题,

Integer patient_id = //get value of patient_id from database
String add1 =patient_id.toString();
p_id.setText(add1);

#1


0  

If I understand your problem correctly,

如果我理解你的问题,

Integer patient_id = //get value of patient_id from database
String add1 =patient_id.toString();
p_id.setText(add1);