将整数转换为字符串NOT NUMERIC [英] Converting an Integer into a string NOT NUMERIC
问题描述
所以我想做的是将jdbc中的INTEGER类型转换为字符串以放入jtextfield中,不幸的是String.OfValue不能转换我的Integer类型,但可以转换为NUMBERIC类型.
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.
**未使用数字,因为出于某些奇怪的原因,自动递增不会在数字上起作用(如果您知道解决方法,请告诉我)
**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)
使用我的字符串方法
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);
}
这是我的错误信息
java.sql.SQLSyntaxErrorException:不支持在"INTEGER"和"CHAR(UCS_BASIC)"之间进行比较.类型必须是可比较的.字符串类型还必须具有匹配的排序规则.如果排序规则不匹配,则可能的解决方案是强制转换操作数以将其强制为默认排序规则(例如SELECT tablename FROM sys.systables WHERE CAST(tablename AS VARCHAR(128))='T1')
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')
推荐答案
如果我正确理解了您的问题,
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);
这篇关于将整数转换为字符串NOT NUMERIC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!