MySQL|使用Java Spring消费MySQL中的数据库存储过程( 二 )


Beans.xml:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd "><bean id="dataSource"class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="https://www.360kuai.com/com.mysql.jdbc.Driver"/> <property name="url" value="https://www.360kuai.com/jdbc:mysql://localhost:3306/TEST"/> <property name="username" value="https://www.360kuai.com/root"/> <property name="password" value="https://www.360kuai.com/123456"/> bean>
<bean id="studentJDBCTemplate"class="com.sap.StudentJDBCTemplate"> <property name="dataSource" ref="dataSource" />bean>beans> 执行MainApp.java前,先清空student数据库表:
truncate table student;
 MySQL|使用Java Spring消费MySQL中的数据库存储过程
文章图片
输出:
 MySQL|使用Java Spring消费MySQL中的数据库存储过程
文章图片
Jul 30, 2020 1:20:46 PM org.springframework.context.support.ClassPathXmlApplicationContext prepareRefreshINFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@32a1bec0: startup date [Thu Jul 30 13:20:46 CST 2020]; root of context hierarchyJul 30, 2020 1:20:46 PM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitionsINFO: Loading XML bean definitions from class path resource [Beans.xml]Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.Jul 30, 2020 1:20:46 PM org.springframework.jdbc.datasource.DriverManagerDataSource setDriverClassNameINFO: Loaded JDBC driver: com.mysql.jdbc.Driver------Records Creation--------Created Record Name = Zara Age = 11Created Record Name = Nuha Age = 2Created Record Name = Ayan Age = 15------Listing Multiple Records--------ID : 1, Name : Zara, Age : 11ID : 2, Name : Nuha, Age : 2ID : 3, Name : Ayan, Age : 15----Listing Record with ID = 2 -----ID : 2, Name : Nuha, Age : 2
【来源:汪子熙的游泳故事】
【 MySQL|使用Java Spring消费MySQL中的数据库存储过程】声明:转载此文是出于传递更多信息之目的。若有来源标注错误或侵犯了您的合法权益,请作者持权属证明与本网联系,我们将及时更正、删除,谢谢。 邮箱地址:newmedia@xxcb.cn


推荐阅读