package CRUD_cn;
import java.sql.Connection;
import java.sql.PreparedStatement;
import org.junit.Test;
public class API {
@Test
public void test() throws Exception{
// String sql="INSERT INTO student (id,type,studentName,location,grade)VALUES(?,?,?,?,?)";
// String sql="UPDATE EMPLOYEE SET EMAIL='12345@QQ.COM'"+
// "WHERE ID= ?";
String sql="DELETE FROM student WHERE id=?";
API I =new API();
I.update(sql,6);
}
//通用的增,删,改
public void update(String sql,Object ...args) throws Exception{
Connection connection =null;
PreparedStatement preparedstatement = null;
JDBC s=new JDBC();
connection=s.getSQL();
preparedstatement=connection.prepareStatement(sql);
for(int i=0;i<args.length;i++){
preparedstatement.setObject(i+1,args[i]);
}
preparedstatement.executeUpdate();
s.closeResources(preparedstatement, connection, null);
}
}
import java.sql.Connection;
import java.sql.PreparedStatement;
import org.junit.Test;
public class API {
@Test
public void test() throws Exception{
// String sql="INSERT INTO student (id,type,studentName,location,grade)VALUES(?,?,?,?,?)";
// String sql="UPDATE EMPLOYEE SET EMAIL='12345@QQ.COM'"+
// "WHERE ID= ?";
String sql="DELETE FROM student WHERE id=?";
API I =new API();
I.update(sql,6);
}
//通用的增,删,改
public void update(String sql,Object ...args) throws Exception{
Connection connection =null;
PreparedStatement preparedstatement = null;
JDBC s=new JDBC();
connection=s.getSQL();
preparedstatement=connection.prepareStatement(sql);
for(int i=0;i<args.length;i++){
preparedstatement.setObject(i+1,args[i]);
}
preparedstatement.executeUpdate();
s.closeResources(preparedstatement, connection, null);
}
}