- Timestamp:
- 2019-02-05T23:03:16+13:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
other-projects/the-macronizer/trunk/src/java/util/MySQLAccess.java
r32743 r32745 56 56 57 57 private final String DB_NAME = "Macroniser"; 58 // TODO: from Properties file58 // obtained from Properties file: 59 59 private String USERNAME; //= "root"; by default 60 60 private String PASSWORD; //= "pinky"; … … 91 91 92 92 } 93 System.err.println("*** Found user: |" + USERNAME + "|");94 System.err.println("*** Found pwd: " + PASSWORD);93 //System.out.println("*** Found user: |" + USERNAME + "|"); 94 //System.out.println("*** Found pwd: " + PASSWORD); 95 95 96 96 // This will load the MySQL driver, each DB has its own driver Class.forName("com.mysql.jdbc.Driver"); … … 99 99 statement = connect.createStatement(); 100 100 101 // TODO: can we use preparedStatement here instead of statement? 102 int result = statement.executeUpdate("set names utf8mb4"); 103 System.err.println("Was set utf8 a success? " + result); // should return 0 for SQL stmts that return nothing 101 int result = statement.executeUpdate("set names utf8mb4"); // should return 0 for SQL stmts that return nothing 102 104 103 success = true; 105 104 } catch (SQLException e) { … … 192 191 insertOccurrence(word_id, time_id, date_id); 193 192 194 System.err.println("The ID's are:(word, date, time) (" + word_id + "," + date_id + "," + time_id + ")"); 193 if(MacroniserLogFileProcessor.debug) { 194 System.out.println("The IDs are:(word, date, time) (" + word_id + "," + date_id + "," + time_id + ")"); 195 } 195 196 196 197 connect.commit(); … … 234 235 //gets the specified marked word's id 235 236 private int getMarkedWordID(String marked_word) throws SQLException { 237 // in cases where the user didn't enter any input str, marked_word will be null. Still of interest, store to db as string "NULL" 238 if(marked_word == null) { 239 marked_word = "NULL"; 240 } 241 236 242 // Warning: "select * from table WHERE str_field LIKE ?" does not work when we want exact matches (or matches featuring macrons) 237 243 // Use "WHERE BINARY str_filed = ?" instead … … 253 259 private int insertMarkedWord(String word) throws SQLException { 254 260 261 if(word == null) { 262 word = "NULL"; 263 } 264 255 265 String query = "INSERT INTO MarkedWords (marked_word) VALUES (?)"; 256 266 preparedStatement = connect.prepareStatement(query, Statement.RETURN_GENERATED_KEYS); 257 267 preparedStatement.setString(1, word); 268 258 269 259 270 int word_id = -1; … … 293 304 while (resultSet.next()) { 294 305 date_id = resultSet.getInt("date_id"); 295 System.err.println(date_id + " - " + date.toString());306 if(MacroniserLogFileProcessor.debug) System.out.println(date_id + " - " + date.toString()); 296 307 } 297 308 return date_id; … … 382 393 383 394 public static void main(String[] args) { 384 System.err.println("Hello pinky!");385 395 MySQLAccess mysql = new MySQLAccess(); 386 396
Note:
See TracChangeset
for help on using the changeset viewer.