private static boolean insertIntoNewTable() {
Connection dbConnection = getDBConnection();
System.out.println("CONNECTED TO DB");
PreparedStatement preparedStatement = null;
String countString;
String fileName;
String seed;
ResultSet rs = null;
BufferedReader br = new BufferedReader(new FileReader("/home/aoblah/Documents/Metaphor-July/Russian/MotherRussia"));
String line;
while(null != (line = br.readLine())){
splitsVille = line.split(":");
fileName = splitsVille[0].trim();
seed = splitsVille[1].trim();
countString = "SELECT COUNT(*) FROM metaphor_repository.source_domain_russian_OY2_v3 where filename = ? AND seed = ?" ;
preparedStatement = dbConnection.prepareStatement(countString);
preparedStatement.setString(1, fileName);
preparedStatement.setString(2, seed);
rs = preparedStatement.executeQuery();
if (rs.next()) {
int numberOfRows = rs.getInt(1);
System.out.println("numberOfRows= " + numberOfRows);
} else {
System.out.println("error: could not get the record counts");
}
}
rs.close();
preparedStatement.close();
dbConnection.close();
return true;
}
I need the row count to be generated by this code but all I get are zeroes. When I execute the same query in MySQL workbench I get correct answer. Please help me find the problem.
I figure out what the problem is. The second columen in the where clause contains Russian characters and they showed up as "?????" when I printed it out. They printout fine in the console when I print them out separately.