some bot overhauls
This commit is contained in:
@@ -20,9 +20,9 @@ public class DBCPDataSource {
|
||||
static {
|
||||
try {
|
||||
ds.setDriver(new com.mysql.cj.jdbc.Driver());
|
||||
ds.setUrl("jdbc:mysql://104.248.40.216:3306/ArtificialAutism?useLegacyDatetimeCode=false&serverTimezone=UTC");
|
||||
ds.setUrl("jdbc:mysql://163.172.84.14:3306/ArtificialAutism?useLegacyDatetimeCode=false&serverTimezone=UTC");
|
||||
ds.setUsername("root");
|
||||
ds.setPassword("fb345972349fnsDW234/¤)#2");
|
||||
ds.setPassword("FJEF23423u5r9BFhBFEBFIB234h29");
|
||||
ds.setMaxTotal(-1);
|
||||
ds.setMinIdle(5);
|
||||
ds.setMaxIdle(-1);
|
||||
|
||||
@@ -38,12 +38,6 @@ public class DataMapper {
|
||||
+ "ENGINE = InnoDB;";
|
||||
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
||||
l_pStatement.execute();
|
||||
l_sSQL = "CREATE TABLE IF NOT EXISTS `ArtificialAutism`.`WordMatrix` (`Str1` VARCHAR(254) NOT NULL, `Str2` VARCHAR(254) NOT NULL,\n"
|
||||
+ " `Distance` DOUBLE NOT NULL, `ID` INT NOT NULL AUTO_INCREMENT,\n"
|
||||
+ " PRIMARY KEY (`ID`))\n"
|
||||
+ "ENGINE = InnoDB;";
|
||||
l_pStatement = l_cCon.prepareStatement(l_sSQL);
|
||||
l_pStatement.execute();
|
||||
} catch (SQLException ex) {
|
||||
throw new CustomError("failed in DataMapper " + ex.getMessage());
|
||||
} finally {
|
||||
@@ -87,7 +81,7 @@ public class DataMapper {
|
||||
java.sql.ResultSet.CONCUR_READ_ONLY);
|
||||
l_pStatement.setFetchSize(Integer.MIN_VALUE);
|
||||
for (String str1 : str.values()) {
|
||||
System.out.println("adding str1: " + str1 + "\n");
|
||||
//System.out.println("adding str1: " + str1 + "\n");
|
||||
l_pStatement.setString(1, str1);
|
||||
l_pStatement.addBatch();
|
||||
}
|
||||
@@ -99,81 +93,6 @@ public class DataMapper {
|
||||
}
|
||||
}
|
||||
|
||||
public static int getSementicsDBRows() {
|
||||
int count = 0;
|
||||
try (Connection l_cCon = DBCPDataSource.getConnection()) {
|
||||
try (Statement s = l_cCon.createStatement();
|
||||
ResultSet r = s.executeQuery("SELECT COUNT(*) AS rowcount FROM WordMatrix")) {
|
||||
r.next();
|
||||
count = r.getInt("rowcount");
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public static void insertSementicMatrixes(ConcurrentMap<Integer, SimilarityMatrix> WS4JListUpdate) throws CustomError {
|
||||
Connection l_cCon = null;
|
||||
PreparedStatement l_pStatement = null;
|
||||
ResultSet l_rsSearch = null;
|
||||
String l_sSQL = "INSERT IGNORE `WordMatrix` (`Str1`,`Str2`,`Distance`) VALUES (?, ?, ?)";
|
||||
try {
|
||||
l_cCon = DBCPDataSource.getConnection();
|
||||
l_pStatement = l_cCon.prepareStatement(l_sSQL, java.sql.ResultSet.TYPE_FORWARD_ONLY,
|
||||
java.sql.ResultSet.CONCUR_READ_ONLY);
|
||||
l_pStatement.setFetchSize(0);
|
||||
System.out.println("Matrix update size: " + WS4JListUpdate.size());
|
||||
for (SimilarityMatrix ws4j : WS4JListUpdate.values()) {
|
||||
l_pStatement.setString(1, ws4j.getPrimaryString());
|
||||
l_pStatement.setString(2, ws4j.getSecondaryString());
|
||||
l_pStatement.setDouble(3, ws4j.getDistance());
|
||||
l_pStatement.addBatch();
|
||||
}
|
||||
l_pStatement.executeBatch();
|
||||
} catch (SQLException ex) {
|
||||
throw new CustomError("failed in DataMapper " + ex.getMessage());
|
||||
} finally {
|
||||
CloseConnections(l_pStatement, l_rsSearch, l_cCon);
|
||||
}
|
||||
}
|
||||
/*
|
||||
public static LinkedHashMap<String, LinkedHashMap<String, Double>> getAllRelationScores() {
|
||||
int count = getSementicsDBRows();
|
||||
LinkedHashMap<String, LinkedHashMap<String, Double>> LHMSMX = new LinkedHashMap();
|
||||
try (Connection l_cCon = DBCPDataSource.getConnection()) {
|
||||
l_cCon.setAutoCommit(false);
|
||||
String l_sSQL = "SELECT * FROM `WordMatrix`";
|
||||
try (PreparedStatement l_pStatement = l_cCon.prepareStatement(l_sSQL, java.sql.ResultSet.TYPE_FORWARD_ONLY,
|
||||
java.sql.ResultSet.CONCUR_READ_ONLY)) {
|
||||
l_pStatement.setFetchSize(0);
|
||||
try (ResultSet l_rsSearch = l_pStatement.executeQuery()) {
|
||||
l_rsSearch.setFetchSize(0);
|
||||
int i = 0;
|
||||
LinkedHashMap<String, Double> LHMLocal = new LinkedHashMap();
|
||||
while (l_rsSearch.next()) {
|
||||
String str1 = l_rsSearch.getString(1);
|
||||
String str2 = l_rsSearch.getString(2);
|
||||
Double score = l_rsSearch.getDouble(3);
|
||||
LHMLocal.put(str2, score);
|
||||
while (l_rsSearch.next() && str1.equals(l_rsSearch.getString(1))) {
|
||||
str2 = l_rsSearch.getString(2);
|
||||
score = l_rsSearch.getDouble(3);
|
||||
LHMLocal.put(str2, score);
|
||||
i++;
|
||||
}
|
||||
LHMSMX.put(str1, LHMLocal);
|
||||
System.out.println("i: " + i + "\n" + "free memory: " + Runtime.getRuntime().freeMemory() + "\n");
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
Logger.getLogger(DataMapper.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}
|
||||
return LHMSMX;
|
||||
}
|
||||
*/
|
||||
public static ConcurrentMap<Integer, String> getHLstatsMessages() {
|
||||
ConcurrentMap<Integer, String> hlStatsMessages = new MapMaker().concurrencyLevel(2).makeMap();
|
||||
try (Connection l_cCon = DBCPDataSourceHLstats.getConnection()) {
|
||||
|
||||
Reference in New Issue
Block a user