Background
I believe most people are currently using Spring + STRUTS2/SPRINGMVC + Hibernate to build the overall architecture of the project, but in the use of the Tibetan will encounter some strange problems, do not know if the solution, today I encountered a very strange problem, That is the connection database hint Java.sql.sqlexception:ora-01017:invalid Username/password; Logon denied, the Chinese meaning of this sentence means that my password or user name has a problem, but I log in alone with Sqlplus, or use the password inside the configuration file, at this time and can log in, anyway, I was torn not to ride elder sister
Problems encountered
1. The contents of the database properties file are as follows
1 username=c# #test 2 password=test 3 Url=jdbc:oracle:thin: @localhost: 1521:orcl 4 Driverclassname=oracle.jdbc.driver.oracledriver 5 Hibernate.dialect=org.hibernate.dialect.oracle10gdialect 6 hibernate.show_sql=true 7 Hibernate.show_format=true
The attribute configuration code snippet for hibernate in 2.applicationcontext.xml is as follows
<BeanID= "DataSource"class= "Org.springframework.jdbc.datasource.DriverManagerDataSource"> < Propertyname= "Driverclassname"value= "${driverclassname}"/> < Propertyname= "url"value= "${url}"/> <property name= "username" value= "${username}"/> < Propertyname= "Password"value= "${password}"/> </Bean> <BeanID= "Sessionfactory"class= "Org.springframework.orm.hibernate4.LocalSessionFactoryBean"> < Propertyname= "DataSource"ref= "DataSource"/> < Propertyname= "Hibernateproperties"> <Props> <propKey= "Hibernate.dialect">${hibernate.dialect}</prop> <propKey= "Hibernate.show_sql">${hibernate.show_sql}</prop> <propKey= "Hibernate.show_format">${hibernate.show_format}</prop> <propKey= "Hibernate.hbm2ddl.auto">Update</prop> </Props> </ Property> < Propertyname= "Packagestoscan"value= "Com.my.resume.entity"/> </Bean>
In this configuration, notice the black bold part, that is, the user name of our login database ( Here we gave his key to username in the previous properties file), the problem is here, I was found in debug, Here the value of username is C # #test, but every time I debug, the incoming username value is not C # #test, I really depressed ah, depressed when also found a strange thing, that is the incoming username although not my designated c## Test, but is a very special value, that is, the user name of my computer (My computer's user name is Aaron, each is passed this parameter), the system environment must be familiar with the people know, so here the solution is: do not use username as the database user name key, You can change it.
Strange anomalies in the use of the SSH framework