Source:
<code>public void store(Item item, String alias) { if (item.getState() instanceof UnDefType) { return; } if (initialized == false) { return; } if (!isConnected()) { connectToDatabase(); } if (!isConnected()) { logger.warn( "mySQL: No connection to database. Can not persist item '{}'! " + "Will retry connecting to database when error count:{} equals errReconnectThreshold:{}", item, errCnt, errReconnectThreshold); return; } String tableName = getTable(item); if (tableName == null) { logger.error("Unable to store item '{}'.", item.getName()); return; } String value; if (item instanceof ColorItem) { value = item.getStateAs(HSBType.class).toString(); } else if (item instanceof RollershutterItem) { value = item.getStateAs(PercentType.class).toString(); } else { value = item.getState().toString(); } String sqlCmd = null; PreparedStatement statement = null; try { long timeNow = Calendar.getInstance().getTimeInMillis(); <START> java.sql.Timestamp timestamp = new java.sql.Timestamp(timeNow); <END> sqlCmd = new String( "INSERT INTO " + tableName + " (TIME, VALUE) VALUES(?,?) ON DUPLICATE KEY UPDATE VALUE=?;"); statement = connection.prepareStatement(sqlCmd); statement.setTimestamp(1, timestamp); statement.setString(2, value); statement.setString(3, value); statement.executeUpdate(); logger.debug("mySQL: Stored item '{}' as '{}'[{}] in SQL database at {}.", item.getName(), item.getState().toString(), value, timestamp.toString()); logger.debug("mySQL: query: {}", sqlCmd); errCnt = 0; } catch (Exception e) { errCnt++; logger.error("mySQL: Could not store item '{}' in database with " + "statement '{}': {}", item.getName(), sqlCmd, e.getMessage()); } finally { if (statement != null) { try { statement.close(); } catch (Exception hidden) { } } } }</code><technical_language>Indentation (consider Eclipse IDE auto-format code). Also, please import java.sql.Timestamp package qualifier</technical_language>

Target:
public void store(Item item, String alias) { if (item.getState() instanceof UnDefType) { return; } if (initialized == false) { return; } if (!isConnected()) { connectToDatabase(); } if (!isConnected()) { logger.warn( "mySQL: No connection to database. Can not persist item '{}'! " + "Will retry connecting to database when error count:{} equals errReconnectThreshold:{}", item, errCnt, errReconnectThreshold); return; } String tableName = getTable(item); if (tableName == null) { logger.error("Unable to store item '{}'.", item.getName()); return; } String value; if (item instanceof ColorItem) { value = item.getStateAs(HSBType.class).toString(); } else if (item instanceof RollershutterItem) { value = item.getStateAs(PercentType.class).toString(); } else { value = item.getState().toString(); } long timeNow = Calendar.getInstance().getTimeInMillis(); Timestamp timestamp = new Timestamp(timeNow); String sqlCmd = null; PreparedStatement statement = null; try { if (localtime) { sqlCmd = new String( "INSERT INTO " + tableName + " (TIME, VALUE) VALUES(?,?) ON DUPLICATE KEY UPDATE VALUE=?;"); statement = connection.prepareStatement(sqlCmd); statement.setTimestamp(1, timestamp); statement.setString(2, value); statement.setString(3, value); } else { sqlCmd = new String( "INSERT INTO " + tableName + " (TIME, VALUE) VALUES(NOW(),?) ON DUPLICATE KEY UPDATE VALUE=?;"); statement = connection.prepareStatement(sqlCmd); statement.setString(1, value); statement.setString(2, value); } statement.executeUpdate(); logger.debug("mySQL: Stored item '{}' as '{}'[{}] in SQL database at {}.", item.getName(), item.getState().toString(), value, timestamp.toString()); logger.debug("mySQL: query: {}", sqlCmd); errCnt = 0; } catch (Exception e) { errCnt++; logger.error("mySQL: Could not store item '{}' in database with " + "statement '{}': {}", item.getName(), sqlCmd, e.getMessage()); } finally { if (statement != null) { try { statement.close(); } catch (Exception hidden) { } } } }