求大神支招啊。。。
这是的hibernate.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<session-factory>
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="connection.url">jdbc:oracle:thin:@127.0.0.1:1521:orcl</property>
<!-- c3lzdGVt cGFuaGFv -->
<property name="connection.username">c3lzdGVt</property>
<property name="connection.password">cGFuaGFv</property>
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="myeclipse.connection.profile">a</property>
<mapping resource="pojo/Nametable.hbm.xml" />
</session-factory>
这是的Sessionfactory里面加载hibernate.xml的部分
static {
try {
configuration.configure(configFile);
//得到hibernate配置文件中的密码
String password = configuration.getProperty("connection.password");
System.out.println("//-配置文件中password:"+password);
//调用密钥解密
String keyword = SimpleDESCrypto.APPOINT_KEY_WORD;
//先用base64解码
byte[] data = SimpleDESCrypto.decodeByBase64(password);
//decrypt解密
String realPassword = new String(SimpleDESCrypto.decrypt(keyword, data));
System.out.println("//---解密后的密码-------realPassword:"+realPassword);
//将解密后的密码设置到hibernate配置文件中
configuration.setProperty("connection.password", realPassword);
String pass=configuration.getProperty("connection.password");
System.out.println("从配置文件中得到的密码"+pass);
sessionFactory = configuration.buildSessionFactory();
} catch (Exception e) {
System.err.println("%%%% Error Creating SessionFactory %%%%");
e.printStackTrace();
}
}
可以得到加密后的密码,然后解密,也可以解出来,再设置到hibernate中的时候就设置不进去了。不知道是什么原因,帮帮忙呀。谢谢。