日期:2014-05-18 浏览次数:20684 次
public static void main(String[] args) throws Exception {
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setDriverClass("oracle.jdbc.OracleDriver");
cpds.setJdbcUrl("jdbc:oracle:thin:@localhost:1521:orcl");
cpds.setUser("mmc");
cpds.setPassword("mmc");
cpds.setMinPoolSize(5);
cpds.setMaxStatements(50);
cpds.setAcquireIncrement(5);
cpds.setMaxPoolSize(20);
Connection con = cpds.getConnection();
try {
Statement stmt = con.createStatement();
con.setAutoCommit(true);
stmt.executeUpdate("CREATE TABLE tempTab (id VARCHAR(32) ,name VARCHAR(32),age NUMBER,score NUMBER)");
stmt.executeUpdate("delete from tempTab");
stmt.executeUpdate("INSERT INTO tempTab VALUES ('075','joyce',22,90)");
stmt.executeUpdate("INSERT INTO tempTab VALUES ('071','LILY',23,80)");
stmt.executeUpdate("INSERT INTO tempTab VALUES ('072','MOMO',22,88)");
String sql = "SELECT C.id, C.name from tempTab c";