我想用hibernate插入一條記錄。當數據庫用戶名和密碼與所有其他 屬性一起在休眠配置文件中時,它工作正常。xml配置後的編程休眠配置
但是,當我從配置文件的用戶名和密碼中刪除它,我無法插入。我可能做錯了什麼?
Configuration c = new Configuration();
c.configure();
c.setProperty("connection.username", "abc");
c.setProperty("connection.password", "secret");
SessionFactory sessFact = c.buildSessionFactory();
Session sess = sessFact.openSession();
Transaction tx = sess.beginTransaction();
sess.save(inf);
tx.commit();
sess.close();
org.hibernate.exception.GenericJDBCException: Cannot open connection
at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:52)
at org.hibernate.jdbc.ConnectionManager.openConnection
....
Caused by: java.sql.SQLException: invalid arguments in call
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:236)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:414)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(DriverManager.java:525)
at java.sql.DriverManager.getConnection(DriverManager.java:140)
at org.hibernate.connection.DriverManagerConnectionProvider.getConnection(DriverManagerConnectionProvider.java:133)
at org.hibernate.jdbc.ConnectionManager.openConnection(ConnectionManager.java:446)
我要挑最從XML配置文件的屬性,除了uid和密碼。
在此先感謝
非常感謝它! – lali 2011-04-01 17:53:21