package com.wangdonghui.dbcd;
import java.sql.SQLException;
import javax.sql.DataSource;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.JdbcTemplate;
public class JDBCTest {
private ApplicationContext ctx = null;
private JdbcTemplate jdbcTemplate;
{
ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
jdbcTemplate = (JdbcTemplate) ctx.getBean("jdbcTemplate");
System.out.println("fffffffff");
}
@Test
public void test() throws SQLException{
String sql = "insert into people(id,name) values ('5','6')";
int result = jdbcTemplate.update(sql);
System.out.println(result);
}
}
没有空指针,但是到 int result = jdbcTemplate.update(sql);这行代码就不执行也不往下走了,求大神告知