本文介绍了Oracle JDBC和Oracle CHAR数据类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我有一个棘手的问题,Oracle JDBC驱动程序处理 c 。 c> c> $ c> CHAR 到 VARCHAR (当然应该是这样)The above workaround is not desireable as it modifies both the contents of c and ?, AND it makes using indexes on c quite hard.Moving the column from CHAR to VARCHAR (which it should be, of course) is not possible EDIT :这些约束的原因是因为我从开发者的角度提出这个问题 jOOQ ,一个数据库抽象库。所以我的要求是提供一个非常通用的解决方案,不会破坏任何东西在jOOQ的客户端代码。这就是为什么我不是真正的解决方法的大粉丝。这就是为什么我没有访问 CHAR 列的声明。但仍然,我想能够处理这种情况。EDIT: The reasons for these constraints is because I ask this question from the point of view of the developer of jOOQ, a database abstraction library. So my requirements are to provide a very generic solution that doesn't break anything in jOOQ's client code. That is why I'm not really a big fan of the workaround. And that's why I don't have access to that CHAR column's declaration. But still, I want to be able to handle this case.你会做什么?当我想忽略尾随空格时,处理 CHAR 数据类型的好方法是什么?What would you do instead? What's a good practice for handling CHAR data types when I want to ignore trailing whitespace?推荐答案 如果你想要stmt.setString(1, "a"); // This won't return any records返回记录,请尝试conn.prepareStatement("select * from x where c = cast(? as char(4))") 这篇关于Oracle JDBC和Oracle CHAR数据类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-22 20:55
查看更多