package batch;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.mchange.v2.c3p0.*;
public class c3p0demo {
public static void main(String[] args){
// TODO Auto-generated method stub
String sql = "SELECT * FROM TAB_TABLE2 ";
ComboPooledDataSource ds=new ComboPooledDataSource();
try {
ds.setUser( "comoa");
ds.setPassword( "123456");
ds.setJdbcUrl( "jdbc:sybase:Tds:192.168.1.5:5000/comoa");
ds.setDriverClass("com.sybase.jdbc2.jdbc.SybDriver");
//jdbc:mysql://127.0.0.1:3306/test?autoReconnect=true&useUnicode=true&characterEncoding=GB2312
ds.setInitialPoolSize(2);
ds.setMinPoolSize(1);
ds.setMaxPoolSize(10);
ds.setMaxStatements(50);
ds.setMaxIdleTime(60);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try{
Statement stmt=ds.getConnection().createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
}
}catch(SQLException e)
{
e.printStackTrace();
}
ds.close();
System.out.println("asdfasdfasfasf");
}
}
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import com.mchange.v2.c3p0.*;
public class c3p0demo {
public static void main(String[] args){
// TODO Auto-generated method stub
String sql = "SELECT * FROM TAB_TABLE2 ";
ComboPooledDataSource ds=new ComboPooledDataSource();
try {
ds.setUser( "comoa");
ds.setPassword( "123456");
ds.setJdbcUrl( "jdbc:sybase:Tds:192.168.1.5:5000/comoa");
ds.setDriverClass("com.sybase.jdbc2.jdbc.SybDriver");
//jdbc:mysql://127.0.0.1:3306/test?autoReconnect=true&useUnicode=true&characterEncoding=GB2312
ds.setInitialPoolSize(2);
ds.setMinPoolSize(1);
ds.setMaxPoolSize(10);
ds.setMaxStatements(50);
ds.setMaxIdleTime(60);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try{
Statement stmt=ds.getConnection().createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {
System.out.println(rs.getString(1));
System.out.println(rs.getString(2));
}
}catch(SQLException e)
{
e.printStackTrace();
}
ds.close();
System.out.println("asdfasdfasfasf");
}
}