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....
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
SQL> create user "MyCaseSensitiveUser" ...
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...
精彩评论