;
}
catch(Exception e)
{
e.printStackTrace();
}
finally{
try{
cf.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
public static void main(String args) {
String user = "DevTeam";
String password = "DevTeam";
String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
String url = "jdbc:odbc:gfqh2";
ConnectionParam param = new ConnectionParam(driver,url,user,password);
ConnectionFactory cf = null;//new ConnectionFactory(param,new FactoryParam());
try{
cf = new ConnectionFactory(param,new FactoryParam());
ConnectionFactory cf1= new ConnectionFactory(param,new FactoryParam());
Connection conn1 = null;
long time = System.currentTimeMillis();
for (int i=0; i <10;i++)
{
conn1 = cf.getFreeConnection();
Statement stmt = conn1.createStatement();
ResultSet rs = stmt.executeQuery("select * from requests");
if (rs.next())
{
System.out.println("conn1 y");
}
else
{
System.out.println("conn1 n");
}
conn1.close();
}
System.out.println("pool:" + (System.currentTimeMillis()-time));
time = System.currentTimeMillis();
Class.forName(param.getDriver()).newInstance();
for (int i=0; i <10;i++)
{
conn1 = DriverManager.getConnection(param.getUrl(),
param.getUser(), param.getPassword());
Statement stmt = conn1.createStatement();
ResultSet rs = stmt.executeQuery("select * from requests");
if (rs.next())
{
System.out.println("conn1 y");
}
else
{
System.out.println("conn1 n");
}
conn1.close();
}
System.out.println("no pool:" + (System.currentTimeMillis()-time));
}
catch(Exception e)
{
e.printStackTrace();
}
finally{
try{
cf.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
}