package DruidSt;
import utils.JDBCutils;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
public class DruidDemo2 {
public static void main(String[] args) {
//完成一个添加的操作
Connection conn = null;
PreparedStatement pstmt=null;
try {
conn = JDBCutils.getConnection();
//定义SQL
String sql =“insert into account values(null ,?,?)”;//这里ID使用的是自增长类型所以填NULL
//获取对象
pstmt= conn.prepareStatement(sql);
//给?赋值
pstmt.setString(1,“王五”);
pstmt.setString(2,“3000”);
//执行sql
int count=pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}finally {
//释放资源
JDBCutils.close(pstmt,conn);
}
}
}