💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
## 配置 ~~~ <?xml version="1.0" encoding="UTF-8"?> <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.xsd"> <!--配置JDBCTemplate--> <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate"> <property name="dataSource" ref="dataSource"/> </bean> <!--配置数据源--> <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="com.mysql.jdbc.Driver"/> <property name="url" value="jdbc:mysql://192.168.10.10:3306/jdbc"/> <property name="username" value="homestead"/> <property name="password" value="secret"/> </bean> </beans> ~~~ ## 测试 ~~~ //获取容器 ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml"); //获取数据源 JdbcTemplate jt = (JdbcTemplate) context.getBean("jdbcTemplate"); //执行SQL jt.execute("insert into account values (3,'richard',1000)"); ~~~