BeanFactory applicationContext = new ClassPathXmlApplicationContext("bean.xml");
dataSource = (DataSource)applicationContext.getBean("dataSource"); try{ Connection conn = dataSource.getConnection(); conn.createStatement().executeUpdate("insert into user1(name,passwd)values('"+u.getName()+"','"+u.getPhone()+"')"); conn.close(); }catch (SQLException e){ e.printStackTrace(); }