package com.gyarmy.c3p0;
import java.sql.Connection;
import java.sql.PreparedStatement;
import org.junit.Test;
import com.gyramy.utils.JdbcUtils;
import com.mchange.v2.c3p0.*;
public class C3P0Test {
@Test
public void test2(){
Connection conn =null;
PreparedStatement stmt = null;
try {
ComboPooledDataSource cpds = new ComboPooledDataSource();
conn = cpds.getConnection();
System.out.println(conn);
stmt = conn.prepareStatement("update account set money=? where name=? ");
stmt.setDouble(1, 111111);
stmt.setString(2, "cc");
stmt.executeUpdate();
System.err.println("www.baidu.com");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally{
JdbcUtils.release(null, stmt, conn);
}
}
@Test
public void test1(){
Connection conn =null;
PreparedStatement stmt = null;
try {
ComboPooledDataSource cpds = new ComboPooledDataSource();
cpds.setDriverClass( "com.mysql.jdbc.Driver" ); //loads the jdbc driver
cpds.setJdbcUrl( "jdbc:mysql:///test003" );
cpds.setUser("root");
cpds.setPassword("abc");
conn = cpds.getConnection();
stmt = conn.prepareStatement("update account set money=? where name=? ");
stmt.setDouble(1, 666);
stmt.setString(2, "aa");
stmt.executeUpdate();
System.err.println("www.baidu.com");
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally{
JdbcUtils.release(null, stmt, conn);
}
}
}