package com.test;
import java.io.FileInputStream;
import java.sql.Connection;
import java.util.Properties;
import javax.sql.DataSource;
import org.springframework.jdbc.core.JdbcTemplate;
import com.alibaba.druid.pool.DruidDataSourceFactory;
public class Test5 {
public static void main(String[] args) {
// 创建Properties对象
Properties properties = new Properties();
try {
properties.load(new FileInputStream("src/druid.properties"));
DataSource createDataSource = DruidDataSourceFactory.createDataSource(properties);
JdbcTemplate template = new JdbcTemplate(createDataSource);
int i = template.update("insert into u_p values(null,'ddf','dfd')");
System.out.println(i);
} catch (Exception e) {
e.printStackTrace();
}
}
}
SpringJDBC使用例子
最新推荐文章于 2024-03-31 12:38:32 发布