时间:2021-07-01 10:21:17 帮助过:20人阅读
@Test
public void testSatement(){
Connection connection=null;
Statement statement=null;
ResultSet resultSet=null;
try {
//1.获取数据库连接
connection=getConnection();
//2.调用Connection对象的createStatement()方法获取Statement对象
statement=connection.createStatement();
//3.准备SQL语句
String sql="update customers set name=‘Jerry‘ where id=6";
//4.发送SQL语句:调用Statement对象的executeUpdate(sql)方法
statement.executeUpdate(sql);
} catch (Exception e) {
e.printStackTrace();
}finally{
//5.关闭数据库资源:由里向外关闭
releaseDB(resultSet, statement, connection);
}
比如上述测试中需保证方法getConnection()和releaseDB(resultSet, statement, connection)不应有【@Test】,负责就会报上述错误
注:junit4----junit_4.12.0.v201504281640
jdbc:关于junit测试No tests found matching
标签:exec str 语句 获取 connect exce junit ring null