Oracle11g 的 Hibernate 用户名密码区分大小写
我将 Hibernate
与 Oracle 11g 一起使用。适用于 10g 的代码不适用于 11g,因为 hibernate 将用户名的大小写从示例:admin 更改为 ADMIN。 Oracle 11g 默认情况下创建区分大小写的用户名和密码。在意识到我的代码之前,我已经创建了用户和很多对象:
Context initCtx = new InitialContext();
Context envCtx = (Context)initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("jdbc/AdminDS");
Connection con = ds.getConnection();
连接不起作用,因为数据库中的用户名是小写 admin ,而 hibernate 将其转换为大写 ADMIN。
我尝试了多种方法...包括使用小写用户名、密码创建连接;例如, ds.getConnection("admin","password")...没有骰子...关于如何将用户名转换为小写的任何想法,因为在部署时...
I'm using Hibernate
with Oracle 11g. The code that worked with 10g doesn't work with 11g because hibernate changes the case of the username from example: admin to ADMIN. Oracle 11g by default creates case sensitive usernames and passwords. I've already created the user and a lot of objects before realizing that my code:
Context initCtx = new InitialContext();
Context envCtx = (Context)initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("jdbc/AdminDS");
Connection con = ds.getConnection();
The connection doesn't work because the username in the database is lowercase admin and hibernate converts it to uppercase ADMIN.
I've tried multiple things....including creating the connection with the lowercase username, password; e.g., ds.getConnection("admin","password")....no dice....any ideas as to how to convert the username to lowercase because at deploy time....
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
默认情况下,任何版本的 Oracle 都会创建区分大小写的用户名。您始终(至少在过去 15-20 年)能够创建区分大小写的用户名,但在创建用户名时必须将用户名用双引号引起来。假设
您在 11g 数据库中运行了与 10g 中相同的 DDL,这意味着您没有在
CREATE USER
语句中的用户名周围添加双引号,并且用户名事实上,不区分大小写。在11g中,Oracle确实开始默认使用区分大小写的密码。因此,我认为问题在于从 Hibernate 传入的密码没有使用正确的大小写。您可以通过更改 SEC_CASE_SENSITIVE_LOGON 初始化参数来禁用数据库中区分大小写的密码,恢复到 10g 行为。希望更熟悉 Hibernate 的人可以建议如何让 Hibernate 以区分大小写的方式将密码发送到数据库。
No version of Oracle creates case sensitive user names by default. You have always (at least, for the past 15-20 years) been able to create case sensitive user names but you would have to enclose the user name in double quotes when creating it. Something like
Assuming that you ran the same DDL in the 11g database that you did in 10g, that implies that you didn't add double-quotes around the username in your
CREATE USER
statement and that the user name is not, in fact, case sensitive.In 11g, Oracle did start to use case sensitive passwords by default. I assume, therefore, that the problem is that the password being passed in from Hibernate is not using the proper casing. You can disable case sensitive passwords in the database, reverting to the 10g behavior, by changing the
SEC_CASE_SENSITIVE_LOGON
initialization parameter. Hopefully someone that is more familiar with Hibernate can suggest how to get Hibernate to send passwords to the database in a case sensitive fashion.这似乎是一个愚蠢的答案,但当我遇到这个问题时,我只需将密码更改为全大写密码即可。这不是我理想的解决方案...
This may seem like a foolish answer, but when I had this problem I simply changed my password to an all uppercase password and it worked. Not my ideal solution...