spring连接基本的数据源
import javax.sql.DataSource;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.jdbc.object.SqlUpdate;
public class Test {
/**
* @param args
*/
public static void main(String[] args) {
Test test=new Test();
JdbcTemplate jt = new JdbcTemplate();
jt.setDataSource(test.getDataSource());
SqlUpdate su = new SqlUpdate();
su.setJdbcTemplate(jt);
su.setSql("UPDATE ct_cuinfo t set vc2cuname='bbb' where numcuguid=1068");
su.compile();
su.update();
}
/**
* 创建数据源
* @return
*/
public DataSource getDataSource(){
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("oracle.jdbc.driver.OracleDriver");
dataSource.setUrl("jdbc:oracle:thin:@172.16.49.55:1521:orcl");
dataSource.setUsername("tht");
dataSource.setPassword("tht");
return dataSource;
}
}