From: fhanik Date: Mon, 3 Jan 2011 20:11:50 +0000 (+0000) Subject: better count check X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=3e109b593136dbb49b671332f326ebba95a71e04;p=tomcat7.0 better count check git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1054730 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CreateTestTable.java b/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CreateTestTable.java index 9242d7d4b..825cb0073 100644 --- a/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CreateTestTable.java +++ b/modules/jdbc-pool/test/org/apache/tomcat/jdbc/test/CreateTestTable.java @@ -55,18 +55,30 @@ public class CreateTestTable extends DefaultTestCase { if (rs.next()) count = rs.getInt(1); + rs.close(); + st.close(); System.out.println("Count:"+count); }catch (Exception ignore) {} + con.close(); return count; } public void testPopulateData() throws Exception { - init(); + int count = 100000; + int actual = testCheckData(); + if (actual>=count) { + System.out.println("Test tables has "+actual+" rows of data. No need to populate."); + return; + } + datasource.setJdbcInterceptors(ResetAbandonedTimer.class.getName()); String insert = "insert into test values (?,?,?,?,?)"; this.init(); this.datasource.setRemoveAbandoned(false); Connection con = datasource.getConnection(); + + boolean commit = con.getAutoCommit(); + con.setAutoCommit(false); if (recreate) { Statement st = con.createStatement(); try { @@ -75,9 +87,11 @@ public class CreateTestTable extends DefaultTestCase { st.execute("create table test(id int not null, val1 varchar(255), val2 varchar(255), val3 varchar(255), val4 varchar(255))"); st.close(); } + + PreparedStatement ps = con.prepareStatement(insert); ps.setQueryTimeout(0); - for (int i=testCheckData(); i<100000; i++) { + for (int i=actual; i