user=Lfpassword=lfurl=jdbc:oracle:thin: @localhost: 1521: Orcldriver= Oracle.jdbc.driver.OracleDriver
<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "Http://www.springframework.org/schema/beans"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xmlns:p= "http://www.springframework.org/schema/p"Xmlns:context= "Http://www.springframework.org/schema/context"xsi:schemalocation= "Http://www.springframework.org/schema/beans Http://www.springframework.org/schema/beans/spring-beans . xsd Http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-cont Ext.xsd "> <Context:property-placeholder Location= "Classpath:jdbc.properties"/> <BeanID= "Connection"class= "Org.springframework.jdbc.datasource.DriverManagerDataSource"> < Propertyname= "username"value= "${user}"></ Property> < Propertyname= "Password"value= "${password}"></ Property> < Propertyname= "Driverclassname"value= "${driver}"></ Property> < Propertyname= "url"value= "${url}"></ Property> </Bean> </Beans>
public class Utils_jdbc {public static void Main (string[] args) { ApplicationContext CTC = new Classpathxmlapplic Ationcontext ("Applicationcontext.xml"); Drivermanagerdatasource Dsource = (drivermanagerdatasource) ctc.getbean ("Connection"); try { System.out.println (dsource.getconnection ()); } catch (SQLException e) { e.printstacktrace (); } } }
Spring Framework JDBC Connection database