List of utility methods to do JDBC MySQL Connection
List | readMapListBySQL(String driverClass, String host, String port, String database, String user, String password, String sql) read Map List By SQL Class.forName(driverClass); StringBuilder url = new StringBuilder(); url.append("jdbc:mysql://"); url.append(host); url.append(":"); url.append(port); url.append("/"); url.append(database); ... |
void | removeById(int Id) remove By Id try { conn = DriverManager.getConnection("jdbc:mysql://localhost/sbs_db?" + "user=root&password="); preparedStatement = conn.prepareStatement("DELETE FROM sbs_userdata WHERE Id=" + Id); preparedStatement.executeUpdate(); } catch (SQLException e) { System.err.println("Error occurs while delete entry from database!"); e.printStackTrace(); } finally { ... |
int | searchForItemId(String item) search For Item Id Connection dbConnection = null; PreparedStatement preparedStatement = null; String sql = "SELECT itemId as id FROM items WHERE itemName = ?"; try { dbConnection = getDBConnection(); preparedStatement = dbConnection.prepareStatement(sql); preparedStatement.setString(1, item); logPreparedStatement(preparedStatement); ... |
String | searchServerPropertySplitMinutes() search Server Property Split Minutes String result = "5"; Connection con = null; PreparedStatement pstmt = null; ResultSet rs = null; String sql = "select valor from parametros where chave = ?"; try { con = getConnection(); pstmt = con.prepareStatement(sql); ... |
boolean | tablesOk(String url, String user, String password) tables Ok boolean tablesOk = false; try { Class.forName("com.mysql.jdbc.Driver"); Connection cnn = DriverManager.getConnection(url, user, password); PreparedStatement statement = cnn.prepareStatement("SELECT * FROM st_company where 1 = 2 "); statement.execute(); cnn.close(); tablesOk = true; ... |