Changeset 95


Ignore:
Timestamp:
05/13/16 08:49:56 (9 years ago)
Author:
sherbold
Message:
  • MySQLResultStorage now working with an Apache dbcp connection pool
Location:
trunk/CrossPare
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/CrossPare/.classpath

    r94 r95  
    2626        <classpathentry kind="lib" path="lib/jgap.jar"/> 
    2727        <classpathentry kind="lib" path="lib/commons-lang3-3.4.jar"/> 
     28        <classpathentry kind="lib" path="lib/commons-dbcp2-2.1.1.jar"/> 
    2829        <classpathentry kind="output" path="bin"/> 
    2930</classpath> 
  • trunk/CrossPare/build.xml

    r93 r95  
    3636                <pathelement location="lib/jgap.jar" /> 
    3737                <pathelement location="lib/commons-lang3-3.4.jar" /> 
     38                <pathelement location="lib/dbcp2-2.1.1.jar" /> 
    3839        </path> 
    3940 
  • trunk/CrossPare/src/de/ugoe/cs/cpdp/eval/MySQLResultStorage.java

    r86 r95  
    2424import java.util.Properties; 
    2525 
     26import org.apache.commons.dbcp2.BasicDataSource; 
     27 
     28import com.mysql.jdbc.jdbc2.optional.MysqlDataSource; 
     29 
    2630import de.lmu.ifi.dbs.elki.logging.Logging.Level; 
    2731import de.ugoe.cs.util.console.Console; 
     
    3943     * Connection to the database 
    4044     */ 
    41     private Connection con = null; 
     45    //private Connection con = null; 
     46     
     47    /** 
     48     * Connection pool for the data base. 
     49     */ 
     50    private MysqlDataSource connectionPool = null; 
    4251 
    4352    /** 
     
    95104                             String dbPass) 
    96105    { 
     106        connectionPool = new MysqlDataSource(); 
     107        connectionPool.setUser(dbUser); 
     108        connectionPool.setPassword(dbPass); 
     109        connectionPool.setUrl("jdbc:mysql://" + dbHost + ":" + dbPort + "/" + dbName); 
     110        /* 
    97111        try { 
    98112            Properties connectionProperties = new Properties(); 
     
    102116            connectionProperties.put("maxReconnects", "10000"); 
    103117            Class.forName("com.mysql.jdbc.Driver"); 
     118             
    104119            con = DriverManager.getConnection("jdbc:mysql://" + dbHost + ":" + dbPort + "/" + 
    105120                dbName, connectionProperties); 
     
    114129            Console.printerr("VendorError: " + e.getErrorCode()); 
    115130        } 
     131        */ 
    116132    } 
    117133 
     
    153169        Statement stmt; 
    154170        try { 
    155             stmt = con.createStatement(); 
     171            stmt = connectionPool.getConnection().createStatement(); 
    156172            stmt.executeUpdate(sql.toString().replace("NaN", "NULL")); 
    157173        } 
     
    177193        boolean contained = false; 
    178194        try { 
    179             stmt = con.createStatement(); 
     195            stmt = connectionPool.getConnection().createStatement(); 
    180196            ResultSet results = stmt.executeQuery(sql); 
    181197            results.next(); 
     
    188204            Console.printerr("SQLState: " + e.getSQLState() + "\n"); 
    189205            Console.printerr("VendorError: " + e.getErrorCode() + "\n"); 
     206            Console.printerr("\nskipping product since we could not check if the results is available"); 
     207            contained = true; 
    190208        } 
    191209        return contained; 
Note: See TracChangeset for help on using the changeset viewer.