在Java中有一些框架便于简化程序猿的操作,相较于之前,连接,释放的烦杂,添加Spring中的一些依赖包能减轻不少负担
所需要的资源 jar包下载
import org.springframework.jdbc.core.JdbcTemplate;
public class TemplateText {
public static void main(String[] args) {
//获取Template对象
JdbcTemplate template = new JdbcTemplate(DruidUtils.getDataSource());
//定义sql
String sql = "update student set account =100 where username=111";
//执行sql
int count = template.update(sql);
System.out.println(count);
}
}