Last active
August 29, 2015 14:05
Revisions
-
Aiman Baharum revised this gist
Aug 26, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,7 @@ public static String getSearchResult(String search) { buf.append("<h3>Search Result for <strong>" + search + "</strong></h3>"); // returns true if there are rows in ResultSet while (rs.next()) { buf.append("<p><strong>Data Structure Type:</strong> " + rs.getString("data_structure_type") + "</br>"); buf.append("<strong>Element Name:</strong> " + rs.getString("element_name") + "</br>"); @@ -22,6 +23,7 @@ public static String getSearchResult(String search) { } // No rows found if (!rs.first()){ buf.append("<p><strong>No search result</strong></p>"); } -
Aiman Baharum renamed this gist
Aug 26, 2014 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Aiman Baharum created this gist
Aug 26, 2014 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ public static String getSearchResult(String search) { StringBuilder buf = new StringBuilder(); String searchQuery = "SELECT * FROM data_structure WHERE element_name LIKE '%" + search + "%'"; // String searchQuery = "SELECT * FROM data_structure WHERE data_structure_type LIKE '%" + search + "%' or element_name LIKE '%" + search + "%' or element_description LIKE '%" + search + "%' or rational LIKE '%" + search + "%' or field_namecode LIKE '%" + search + "%' or alias LIKE '%" + search + "%' or field_size LIKE '%" + search + "%' or element_owner LIKE '%" + search + "%'"; try { currentCon = ConnectionManager.getConnection(); stmt = currentCon.createStatement(); rs = stmt.executeQuery(searchQuery); buf.append("<h3>Search Result for <strong>" + search + "</strong></h3>"); while (rs.next()) { buf.append("<p><strong>Data Structure Type:</strong> " + rs.getString("data_structure_type") + "</br>"); buf.append("<strong>Element Name:</strong> " + rs.getString("element_name") + "</br>"); buf.append("<strong>Element Description:</strong> " + rs.getString("element_description") + "</br>"); buf.append("<strong>Field Namecode:</strong> <code>" + rs.getString("field_namecode") + "</code></br>"); buf.append("<strong>Alias:</strong> " + rs.getString("field_namecode") + "</p><hr/>"); } if (!rs.first()){ buf.append("<p><strong>No search result</strong></p>"); } } catch (SQLException e) { System.out.println("Search failed: An Exception has occurred! " + e); } finally { if (rs != null) { try { rs.close(); } catch (SQLException e) { rs = null; } } if (stmt != null) { try { stmt.close(); } catch (SQLException e) { rs = null; } } if (currentCon != null) { try { currentCon.close(); } catch (SQLException e) { } currentCon = null; } } return buf.toString(); }