I am somewhat new to hibernate. I was wondering how to get the username/password@connectstring parameters from the applicationContext-hibernate.xml into my java code?
From the hibernate.xml file: --------------------------------------------------------------------------------------- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="url" value="jdbc:oracle:thin:@vejxsefw3db1506:1521:igdev"/> <property name="username" value="IGEMS"/> <property name="password" value="password"/> ---------------------------------------------------------------------------------------
From my code (I don't want to hard code the username password - I want to get the connection information from the hibernate.xml file) - any ideas?: --------------------------------------------------------------------------------------- String driver = "oracle.jdbc.driver.OracleDriver"; String url = "jdbc:oracle:thin:@localhost:1521:igdev"; // How do I get from hibernate.xml file? String username = "igems"; // How do I get from hibernate.xml file? String password = "Igems12#$"; // How do I get from hibernate.xml file?
Class.forName(driver); // load Oracle driver Connection conn = DriverManager.getConnection(url, username, password);
String proc3StoredProcedure = "{ call ALERT_MAIL_ATTACH(?, ?, ?, ?, ?, ?, ?) }";
CallableStatement cs = conn.prepareCall(proc3StoredProcedure);
cs.setString(1, fromAddress); cs.setString(2, tmpToAddress); cs.setString(3, tmpCcAddress); cs.setString(4, tmpBccAddress); cs.setString(5, subject); cs.setString(6, message); cs.setString(7, tmpAttachments);
cs.execute(); conn.commit(); conn.close(); ---------------------------------------------------------------------------------------
|